Class SettableIdBasedEntity<T extends org.springframework.data.domain.Persistable<Long>>
java.lang.Object
com.foreach.across.modules.hibernate.business.SettableIdBasedEntity<T>
- All Implemented Interfaces:
EntityWithDto<T>
,IdBasedEntity
,org.springframework.data.domain.Persistable<Long>
- Direct Known Subclasses:
SettableIdAuditableEntity
public abstract class SettableIdBasedEntity<T extends org.springframework.data.domain.Persistable<Long>>
extends Object
implements IdBasedEntity, org.springframework.data.domain.Persistable<Long>, EntityWithDto<T>
Base class for an entity with a unique long id, that allows the id to be manually set.
This requires the use of a generator strategy that supports manual ids.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Two non-new entities are considered equal if they have the same id.Returns the id that will forcibly be assigned when persisting this entity.int
hashCode()
final boolean
isNew()
Returns if thePersistable
is new or was persisted already.abstract void
void
setNewEntityId
(Long newEntityId) Forcibly set the entity as new with the specific id.toDto()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.foreach.across.modules.hibernate.business.IdBasedEntity
getId
Methods inherited from interface org.springframework.data.domain.Persistable
getId
-
Constructor Details
-
SettableIdBasedEntity
public SettableIdBasedEntity()
-
-
Method Details
-
setId
-
isNew
public final boolean isNew()Returns if thePersistable
is new or was persisted already. -
setNewEntityId
Forcibly set the entity as new with the specific id. When saving this instance, a new entity should be persisted with the given id.- Parameters:
newEntityId
- id this new entity should be assigned to
-
getNewEntityId
Returns the id that will forcibly be assigned when persisting this entity. This method will only return a non-null call if the entity is new and not yet persisted.- Returns:
- new entity id
- See Also:
-
toDto
- Specified by:
toDto
in interfaceEntityWithDto<T extends org.springframework.data.domain.Persistable<Long>>
- Returns:
- a cloned or detached version of this entity
-
equals
Two non-new entities are considered equal if they have the same id. New entities are only considered equal if they are in fact the same instance. -
hashCode
public int hashCode()
-