SEQUENCE increment for a Class Property – HIBERNATE annotation


 A class’s property can take its value from a SEQUENCE provided by ORACLE DB Server.
 Here is the code for defining a relation between a SEQUENCE and a class field for Hibernate Persistent Framework.

@Entity()
@Table(name = “STAFFS”)
public class Staff implements Serializable
{
@Id
 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator=”STAFFS_SEQ“)
 @SequenceGenerator(name=”STAFFS_SEQ“, sequenceName=”STAFFS_SEQ“)
 @Column (name=”STAFFID”)
 private long staffId;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s