I
- The generic ID type.@MappedSuperclass public abstract class BaseEntity<I extends Comparable<I> & Serializable> extends Object implements Comparable<BaseEntity<I>>, Identifiable<I>, Serializable
Let all your entities extend from this.
Then you can make use of BaseEntityService
.
There are five more mapped superclasses which may also be of interest.
TimestampedBaseEntity
- extends BaseEntity
with created
and lastModified
columns and automatically takes care of them.
VersionedBaseEntity
- extends TimestampedBaseEntity
with a @Version
column and automatically takes care of it.
GeneratedIdEntity
- extends BaseEntity
with id
column and automatically takes care of it.
TimestampedEntity
- extends GeneratedIdEntity
with created
and lastModified
columns and automatically takes care of them.
VersionedEntity
- extends TimestampedEntity
with a @Version
column and automatically takes care of it.
ID
Constructor and Description |
---|
BaseEntity() |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(BaseEntity<I> other)
Orders by default with "nulls last".
|
boolean |
equals(Object other)
Compares by default by entity class (proxies taken into account) and ID.
|
int |
hashCode()
Hashes by default the ID.
|
String |
toString()
The default format is
ClassName[{id}] where {id} defaults to @hashcode when null. |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, setId
public boolean equals(Object other)
public int compareTo(BaseEntity<I> other)
compareTo
in interface Comparable<BaseEntity<I extends Comparable<I> & Serializable>>
Copyright © 2015–2021 OmniFaces. All rights reserved.