69 lines
1.8 KiB
Java
69 lines
1.8 KiB
Java
/*********************************************************************************************************************************
|
|
* Autorskie Prawa Majątkowe - Moose Spółka z ograniczoną odpowiedzialnością
|
|
*
|
|
* Copyright 2017 Moose Spółka z ograniczoną odpowiedzialnością
|
|
********************************************************************************************************************************/
|
|
|
|
package eu.mooseinc.dell.form.entity.base;
|
|
|
|
import javax.persistence.GeneratedValue;
|
|
import javax.persistence.GenerationType;
|
|
import javax.persistence.Id;
|
|
import javax.persistence.MappedSuperclass;
|
|
import javax.persistence.Version;
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
import org.hibernate.annotations.Parameter;
|
|
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
|
|
|
/**
|
|
* Base class for entity.
|
|
*/
|
|
@MappedSuperclass
|
|
public class BaseEntity {
|
|
/**
|
|
* Sequence name.
|
|
*/
|
|
private static final String SEQUENCE_GENERATOR = "registrationform_sequence";
|
|
/**
|
|
* Min value for id.
|
|
*/
|
|
private static final String MIN_SEQUENCE_VALUE = "100";
|
|
/**
|
|
* id in database.
|
|
*/
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE_GENERATOR)
|
|
@GenericGenerator(//
|
|
name = SEQUENCE_GENERATOR,//
|
|
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",//
|
|
parameters = {//
|
|
@Parameter(name = SequenceStyleGenerator.SEQUENCE_PARAM, value = SEQUENCE_GENERATOR),//
|
|
@Parameter(name = SequenceStyleGenerator.INITIAL_PARAM, value = MIN_SEQUENCE_VALUE)//
|
|
})
|
|
private Long id;
|
|
|
|
/**
|
|
* Object version for optimistic locking.
|
|
*/
|
|
@Version
|
|
private long version;
|
|
|
|
/**
|
|
* Returns id of database object.
|
|
*
|
|
* @return id of database object.
|
|
*/
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
/**
|
|
* Returns version of object.
|
|
*
|
|
* @return object version.
|
|
*/
|
|
public long getVersion() {
|
|
return version;
|
|
}
|
|
}
|