Package org.omnifaces.persistence.model
Class BaseEntity<I extends Comparable<I> & Serializable>
java.lang.Object
org.omnifaces.persistence.model.BaseEntity<I>
- Type Parameters:
I
- The generic ID type.
- All Implemented Interfaces:
Serializable
,Comparable<BaseEntity<I>>
,Identifiable<I>
- Direct Known Subclasses:
GeneratedIdEntity
,TimestampedBaseEntity
@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
- extendsBaseEntity
withcreated
andlastModified
columns and automatically takes care of them.VersionedBaseEntity
- extendsTimestampedBaseEntity
with a@Version
column and automatically takes care of it.GeneratedIdEntity
- extendsBaseEntity
withid
column and automatically takes care of it.TimestampedEntity
- extendsGeneratedIdEntity
withcreated
andlastModified
columns and automatically takes care of them.VersionedEntity
- extendsTimestampedEntity
with a@Version
column and automatically takes care of it.
- Author:
- Bauke Scholtz
- See Also:
-
Field Summary
Fields inherited from interface org.omnifaces.persistence.model.Identifiable
ID
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final <E extends BaseEntity<I>>
intint
compareTo
(BaseEntity<I> other) Orders by default with "nulls last".boolean
Compares by default by entity class (proxies taken into account) and ID.protected final <E extends BaseEntity<I>>
booleanint
hashCode()
Hashes by default the ID.protected final <E extends BaseEntity<I>>
inttoString()
The default format isClassName[{id}]
where{id}
defaults to@hashcode
when null.protected final <E extends BaseEntity<I>>
StringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.omnifaces.persistence.model.Identifiable
getId, setId
-
Constructor Details
-
BaseEntity
public BaseEntity()
-
-
Method Details
-
hashCode
public int hashCode()Hashes by default the ID. -
hashCode
-
equals
Compares by default by entity class (proxies taken into account) and ID. -
equals
@SafeVarargs protected final <E extends BaseEntity<I>> boolean equals(Object other, Function<E, Object>... getters) -
compareTo
Orders by default with "nulls last".- Specified by:
compareTo
in interfaceComparable<I extends Comparable<I> & Serializable>
-
compareTo
@SafeVarargs protected final <E extends BaseEntity<I>> int compareTo(Object other, Function<E, Object>... getters) -
toString
The default format isClassName[{id}]
where{id}
defaults to@hashcode
when null. -
toString
@SafeVarargs protected final <E extends BaseEntity<I>> String toString(Function<E, Object>... getters)
-