How do you bind the Id of an Entity to a Sequence ?
jboss recipe of the day
You can define a SequenceGenerator which points to the DB Sequence. Then you link your Id to the SequenceGenerator through the @GeneratedValue annotation. Example:
@Entity
@Table(name="EJB_TASK_VIEWS")
public class View implements Serializable {
@Id()
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="viewSequence" )
@SequenceGenerator( name="viewSequence", sequenceName="VIEW_SEQUENCE")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
.....
}
@Table(name="EJB_TASK_VIEWS")
public class View implements Serializable {
@Id()
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="viewSequence" )
@SequenceGenerator( name="viewSequence", sequenceName="VIEW_SEQUENCE")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
.....
}

