org.silverpeas.persistence.model.jpa
Class AbstractJpaEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>

java.lang.Object
  extended by org.silverpeas.persistence.model.AbstractEntity<ENTITY,IDENTIFIER_TYPE>
      extended by org.silverpeas.persistence.model.jpa.AbstractJpaEntity<ENTITY,IDENTIFIER_TYPE>
Type Parameters:
ENTITY - specify the class name of the entity itself which is handled by a repository manager.
IDENTIFIER_TYPE - the identifier class name used by ENTITY for its primary key definition.
All Implemented Interfaces:
Serializable, Cloneable, Entity<ENTITY,IDENTIFIER_TYPE>
Direct Known Subclasses:
AbstractPeriodDateAsLongJpaEntity, PersistentResourceDateReminder

@MappedSuperclass
public abstract class AbstractJpaEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>
extends AbstractEntity<ENTITY,IDENTIFIER_TYPE>

This abstract class must be extended by all Silverpeas JPA entity definitions. All technical data, excepted the identifier, are handled at this level.

The AbstractEntity.performBeforePersist() and AbstractEntity.performBeforeUpdate() method calls are handled at this level for JPA.

Please be careful into 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 override AbstractEntity.performBeforePersist() or AbstractEntity.performBeforeUpdate() methods without forgetting to play the super call.

Author:
Yohann Chastagnier
See Also:
Serialized Form

Constructor Summary
AbstractJpaEntity()
           
 
Method Summary
 Date getCreateDate()
          Gets the date of the entity creation (in the persistence environment).
 String getCreatedBy()
          Gets the free "created by" data.
protected  Class<IDENTIFIER_TYPE> getEntityIdentifierClass()
          Gets the identifier class of the entity managed by the repository.
 String getId()
          Gets the id of the entity.
 Date getLastUpdateDate()
          Gets the last date and time of the entity update (in the persistence environment).
 String getLastUpdatedBy()
          Gets the free "last updated by" data.
 Long getVersion()
          Gets the version of the entity (in the persistence environment).
 boolean isPersisted()
          Indicates if the entity is persisted (commonly if the entity has an id)
 void markAsModified()
          By default, if no functional data is changed, last update date, last updated by and version technical data are not automatically updated on entity save operation.
protected  IDENTIFIER_TYPE newIdentifierInstance()
           
protected  ENTITY setCreateDate(Date createDate)
           
 ENTITY setCreatedBy(String createdBy)
           
protected  ENTITY setId(String id)
          Sets the id of the entity.
protected  ENTITY setLastUpdateDate(Date lastUpdateDate)
           
 ENTITY setLastUpdatedBy(String lastUpdatedBy)
           
protected  ENTITY setVersion(Long version)
          Sets the version of the entity.
 
Methods inherited from class org.silverpeas.persistence.model.AbstractEntity
clone, equals, getComponentInstanceId, getCreator, getLastUpdater, hasBeenModified, hashCode, performBeforePersist, performBeforeUpdate, setCreator, setLastUpdater
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractJpaEntity

public AbstractJpaEntity()
Method Detail

getEntityIdentifierClass

protected Class<IDENTIFIER_TYPE> getEntityIdentifierClass()
Gets the identifier class of the entity managed by the repository.

Returns:

isPersisted

public boolean isPersisted()
Description copied from interface: Entity
Indicates if the entity is persisted (commonly if the entity has an id)

Specified by:
isPersisted in interface Entity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>
Overrides:
isPersisted in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>
Returns:

getId

public String getId()
Description copied from interface: Entity
Gets the id of the entity.

Returns:

newIdentifierInstance

protected IDENTIFIER_TYPE newIdentifierInstance()

setId

protected ENTITY setId(String id)
Description copied from class: AbstractEntity
Sets the id of the entity.

Specified by:
setId in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>
Parameters:
id - the new id of the entity.
Returns:
the entity instance.

getCreatedBy

public String getCreatedBy()
Description copied from interface: Entity
Gets the free "created by" data.

Returns:

setCreatedBy

public ENTITY setCreatedBy(String createdBy)
Specified by:
setCreatedBy in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>

getCreateDate

public Date getCreateDate()
Description copied from interface: Entity
Gets the date of the entity creation (in the persistence environment).

Returns:

setCreateDate

protected ENTITY setCreateDate(Date createDate)
Specified by:
setCreateDate in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>

getLastUpdateDate

public Date getLastUpdateDate()
Description copied from interface: Entity
Gets the last date and time of the entity update (in the persistence environment).

Returns:

setLastUpdateDate

protected ENTITY setLastUpdateDate(Date lastUpdateDate)
Specified by:
setLastUpdateDate in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>

getLastUpdatedBy

public String getLastUpdatedBy()
Description copied from interface: Entity
Gets the free "last updated by" data.

Returns:

setLastUpdatedBy

public ENTITY setLastUpdatedBy(String lastUpdatedBy)
Specified by:
setLastUpdatedBy in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>

getVersion

public Long getVersion()
Description copied from interface: Entity
Gets the version of the entity (in the persistence environment).

Returns:

setVersion

protected ENTITY setVersion(Long version)
Description copied from class: AbstractEntity
Sets the version of the entity.

Specified by:
setVersion in class AbstractEntity<ENTITY extends Entity<ENTITY,IDENTIFIER_TYPE>,IDENTIFIER_TYPE extends EntityIdentifier>
Returns:

markAsModified

public void markAsModified()
Description copied from interface: Entity
By default, if no functional data is changed, last update date, last updated by and version technical data are not automatically updated on entity save operation. But in some cases, it could be useful that this three above technical data are updated, even if functional data are not changed. So, calling this method ensures that last update date, last updated by and version will be updated.



Copyright © 2016 Silverpeas. All Rights Reserved.