Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1f5f62cd
authored
Mar 30, 2013
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
1 parent
50b03a05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
42 deletions
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/EntityEquals.java
code/MoyaUtilities/src/fi/codecrew/moya/utilities/jpa/EntityEquals.java
View file @
1f5f62c
...
@@ -6,49 +6,45 @@ import java.util.Random;
...
@@ -6,49 +6,45 @@ import java.util.Random;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.MappedSuperclass
;
import
javax.persistence.Transient
;
import
javax.persistence.Transient
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
@MappedSuperclass
@MappedSuperclass
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
abstract
class
EntityEquals
{
public
abstract
class
EntityEquals
{
@Override
@Override
public
final
String
toString
()
{
public
final
String
toString
()
{
return
new
StringBuilder
(
this
.
getClass
().
getCanonicalName
()).
append
(
"["
).
append
(
getId
()).
append
(
"]"
).
toString
();
return
new
StringBuilder
(
this
.
getClass
().
getCanonicalName
()).
append
(
"["
).
append
(
getId
()).
append
(
"]"
).
toString
();
}
}
@Transient
@Transient
private
Integer
rndid
;
private
Integer
rndid
;
protected
abstract
Object
getId
();
protected
abstract
Object
getId
();
@Override
@Override
public
boolean
equals
(
Object
o
)
{
public
boolean
equals
(
Object
o
)
{
boolean
ret
=
false
;
boolean
ret
=
false
;
if
(
this
==
o
)
{
if
(
this
==
o
)
{
ret
=
true
;
ret
=
true
;
}
else
if
(
o
!=
null
&&
o
instanceof
EntityEquals
&&
this
.
getClass
().
getCanonicalName
().
equals
(
o
.
getClass
().
getCanonicalName
()))
{
}
else
if
(
o
!=
null
&&
o
instanceof
EntityEquals
&&
this
.
getClass
().
getCanonicalName
().
equals
(
o
.
getClass
().
getCanonicalName
()))
{
EntityEquals
oobj
=
(
EntityEquals
)
o
;
EntityEquals
oobj
=
(
EntityEquals
)
o
;
if
(
getId
()
==
null
)
{
if
(
getId
()
==
null
)
{
ret
=
(
getRndid
().
equals
(
oobj
.
rndid
));
ret
=
(
getRndid
().
equals
(
oobj
.
rndid
));
}
else
{
}
else
{
ret
=
getId
().
equals
(
oobj
.
getId
());
ret
=
getId
().
equals
(
oobj
.
getId
());
}
}
}
}
return
ret
;
return
ret
;
}
}
private
Integer
getRndid
()
{
private
Integer
getRndid
()
{
if
(
rndid
==
null
)
{
if
(
rndid
==
null
)
{
Random
rng
=
new
Random
(
new
Date
().
getTime
());
Random
rng
=
new
Random
(
new
Date
().
getTime
());
rndid
=
Integer
.
valueOf
(
rng
.
nextInt
());
rndid
=
Integer
.
valueOf
(
rng
.
nextInt
());
}
}
return
rndid
;
return
rndid
;
}
}
@Override
@Override
public
final
int
hashCode
()
{
public
final
int
hashCode
()
{
return
((
rndid
!=
null
||
getId
()
==
null
)
?
getRndid
()
:
getId
().
hashCode
());
return
((
rndid
!=
null
||
getId
()
==
null
)
?
getRndid
()
:
getId
().
hashCode
());
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment