Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
d3e03a0f
Commit
d3e03a0f
authored
11 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
equals() and hashCode()
parent
db424913
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ws/eclipse/HibIntro/src/main/java/session2/User.java
+60
-61
60 additions, 61 deletions
ws/eclipse/HibIntro/src/main/java/session2/User.java
with
60 additions
and
61 deletions
ws/eclipse/HibIntro/src/main/java/session2/User.java
+
60
−
61
View file @
d3e03a0f
...
...
@@ -15,73 +15,72 @@ import javax.persistence.UniqueConstraint;
*/
@Entity
@Table
(
uniqueConstraints
={
@UniqueConstraint
(
columnNames
={
"uid"
}),
@UniqueConstraint
(
columnNames
={
"uidNumber"
})})
@UniqueConstraint
(
columnNames
={
"uidNumber"
})})
public
class
User
{
@Id
@GeneratedValue
private
Long
id
;
public
Long
getId
()
{
return
id
;}
protected
void
setId
(
Long
id
)
{
this
.
id
=
id
;}
@Id
@GeneratedValue
private
Long
id
;
public
Long
getId
()
{
return
id
;}
protected
void
setId
(
Long
id
)
{
this
.
id
=
id
;}
int
uidNumber
;
public
int
getUidNumber
()
{
return
uidNumber
;}
public
void
setUidNumber
(
int
uidNumber
)
{
this
.
uidNumber
=
uidNumber
;}
int
uidNumber
;
public
int
getUidNumber
()
{
return
uidNumber
;}
public
void
setUidNumber
(
int
uidNumber
)
{
this
.
uidNumber
=
uidNumber
;}
String
uid
;
String
uid
;
/**
*
* @return The user's unique login name e.g. "goik"
*/
@Column
(
nullable
=
false
)
public
String
getUid
()
{
return
uid
;}
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;}
/**
*
* @return The user's unique login name e.g. "goik"
*/
@Column
(
nullable
=
false
)
public
String
getUid
()
{
return
uid
;}
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;}
String
cname
;
/**
* @return The user's common name e.g. "Martin Goik"
*/
@Column
(
nullable
=
false
)
public
String
getCname
()
{
return
cname
;}
public
void
setCname
(
String
cname
)
{
this
.
cname
=
cname
;}
String
cname
;
/**
* @return The user's common name e.g. "Martin Goik"
*/
@Column
(
nullable
=
false
)
public
String
getCname
()
{
return
cname
;}
public
void
setCname
(
String
cname
)
{
this
.
cname
=
cname
;}
/**
* Hibernate/JPA require a default constructor
*/
public
User
()
{}
/**
* @param uid
* See {@link #getUid()}.
* @param cname
* See {@link #getCname()}.
*/
public
User
(
int
uidNumber
,
String
uid
,
String
cname
)
{
setUidNumber
(
uidNumber
);
setUid
(
uid
);
setCname
(
cname
);
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(
this
==
other
)
{
return
true
;
}
else
if
(
id
==
null
)
{
return
false
;
}
else
if
(
other
instanceof
User
)
{
final
User
that
=
(
User
)
other
;
return
this
.
id
.
equals
(
that
.
getId
()
);
}
else
{
return
false
;
}
}
@Override
public
int
hashCode
()
{
if
(
null
==
id
)
{
return
System
.
identityHashCode
(
this
);
}
else
{
return
id
.
hashCode
();
}
}
/**
* Hibernate/JPA require a default constructor
*/
public
User
()
{}
/**
* @param uid
* See {@link #getUid()}.
* @param cname
* See {@link #getCname()}.
*/
public
User
(
int
uidNumber
,
String
uid
,
String
cname
)
{
setUidNumber
(
uidNumber
);
setUid
(
uid
);
setCname
(
cname
);
}
@Override
public
boolean
equals
(
Object
other
)
{
if
(
this
==
other
)
{
return
true
;
}
else
if
(
id
==
null
)
{
return
false
;
}
else
if
(
other
instanceof
User
)
{
final
User
that
=
(
User
)
other
;
return
this
.
id
.
equals
(
that
.
getId
()
);
}
else
{
return
false
;
}
}
@Override
public
int
hashCode
()
{
if
(
null
==
id
)
{
return
System
.
identityHashCode
(
this
);
}
else
{
return
id
.
hashCode
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment