|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ID
- Java type of the primary key column.public interface Persistable<ID extends java.io.Serializable>
Generic persistent entity contract used
by the PersistentEntityDao
.
Implementations of this interface must follow some general rules regarding JPA object-relational mapping concepts:
Id
annotation to mark
a single id field to be used
as the primary key. It is common to mark
the id field using the
GeneratedValue
annotation as well
in case the identifier should be
automatically assigned upon persistent
entity creation.
Embeddable
annotation to
mark the primary key class and join it
with the persistent entity using IdClass
and Id
annotations. In case of necessary
primary key field association overrides, it is
advised to use Embeddable
and
EmbeddedId
annotations instead.
Version
annotation to mark an optimistic
lock value (version) field. This way, the underlying
persistence provider is able to enforce optimistic
locking strategy on the persistent entity.
Object.hashCode()
and Object.equals(Object)
implementation which covers all possible entity states.
Object.hashCode()
and Object.equals(Object)
methods:
Object.hashCode()
and Object.equals(Object)
method contract (for example, uniqueness might be
broken if any of the "semi"-unique attributes change,
persistent entity instance has to have all "semi"-unique
attributes set in advance for Object.hashCode()
and
Object.equals(Object)
to work properly, etc.).
Inheritance
annotation
as appropriate. Keep in mind that the default JPA inheritance
strategy is set to InheritanceType.SINGLE_TABLE
along
with its implications on the underlying database schema.
PersistentEntityDao
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |