Class AbstractJpaEntity<T extends IdentifiableEntity,U extends EntityIdentifier>
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<T,U>
-
- Type Parameters:
T
- the class name of the represented entity.U
- the unique identifier class used by the entity to identify it uniquely in the persistence context.
- All Implemented Interfaces:
Serializable
,IdentifiableEntity
- Direct Known Subclasses:
BasicJpaEntity
,SilverpeasJpaEntity
@MappedSuperclass public abstract class AbstractJpaEntity<T extends IdentifiableEntity,U extends EntityIdentifier> extends Object implements IdentifiableEntity
Abstract implementation of theIdentifiableEntity
interface that uses the JPA API. This implementation defines all the common methods that can be required by the more concrete entities and that puts in place the JPA mechanical required for their persistence according to the basic JPA related rules in the Silverpeas Persistence API such as the unique identifier management. Please be careful with the child entity classes about the use of @PrePersist and @PreUpdate annotations. In most of cases you don't need to use them, but to overrideperformBeforePersist()
orperformBeforeUpdate()
methods.- Author:
- mmoquillon
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractJpaEntity()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
String
getId()
Gets the unique identifier of this entity.protected U
getNativeId()
Gets the native representation of the entity identifier.int
hashCode()
boolean
isPersisted()
Indicates if the entity is persisted.protected abstract void
performBeforePersist()
Performs some treatments before this entity is persisted into a repository.protected abstract void
performBeforeRemove()
Performs some treatments before this entity is removed from a repository.protected abstract void
performBeforeUpdate()
Performs some treatments before its counterpart in a repository is updated with the changes in this entity.protected T
setId(String id)
Sets the specified unique identifier to this entity.
-
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:IdentifiableEntity
Gets the unique identifier of this entity.- Specified by:
getId
in interfaceIdentifiableEntity
- Returns:
- the entity unique identifier in the form of a string.
-
isPersisted
public boolean isPersisted()
Description copied from interface:IdentifiableEntity
Indicates if the entity is persisted.- Specified by:
isPersisted
in interfaceIdentifiableEntity
- Returns:
- true if the entity is stored in a data source, false otherwise.
-
getNativeId
protected U getNativeId()
Gets the native representation of the entity identifier.- Returns:
- the native representation of the unique identifier of this entity.
-
setId
protected T setId(String id)
Sets the specified unique identifier to this entity.- Parameters:
id
- the new unique identifier of the entity.- Returns:
- itself.
-
performBeforePersist
protected abstract void performBeforePersist()
Performs some treatments before this entity is persisted into a repository.
-
performBeforeUpdate
protected abstract void performBeforeUpdate()
Performs some treatments before its counterpart in a repository is updated with the changes in this entity.
-
performBeforeRemove
protected abstract void performBeforeRemove()
Performs some treatments before this entity is removed from a repository.
-
-