Package org.fryske_akademy.jpa
Class AbstractEntity
- java.lang.Object
-
- org.fryske_akademy.jpa.AbstractEntity
-
- All Implemented Interfaces:
Serializable,EntityInterface
@MappedSuperclass public class AbstractEntity extends Object implements EntityInterface
superclass for entities, defines auto generated id (GenerationType.IDENTITY), a version column and a function to check if the entity is transient (not in db yet). Jpa annotations are on getters which allows you to override. If you want to annotate fields in your subclasses be sure to annotate withAccessType.FIELD.- Author:
- eduard
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractEntity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)IntegergetId()an entity should have an idintgetVersion()inthashCode()booleanisTransient()is the entity in the db?voidsetId(Integer id)voidsetVersion(int version)
-
-
-
Method Detail
-
getId
public Integer getId()
Description copied from interface:EntityInterfacean entity should have an id- Specified by:
getIdin interfaceEntityInterface- Returns:
-
setId
public void setId(Integer id)
-
getVersion
public int getVersion()
-
setVersion
public void setVersion(int version)
-
isTransient
public boolean isTransient()
is the entity in the db?- Specified by:
isTransientin interfaceEntityInterface- Returns:
- true when version < 0 (version default value is -1) or id is null
-
-