Hi All
I've got a two-column primary key mapped like this:
Code:
@Embeddable
public static class BSCSFeesPk implements Serializable
{
private long customerId;
private long seqNo;
[...]
This is primary key of my entity BSCSFees:
Code:
@Entity
@Table(name="FEES")
@org.hibernate.annotations.Entity(dynamicUpdate=true, dynamicInsert=true)
public class BSCSFees
{
private BSCSFeesPk pk;
@EmbeddedId
public BSCSFeesPk getPk()
{
return pk;
}
[...]
During persisting of the entity I know the first value: customerId
Second value of primary key (seqNo) I'm generating manually hitting database sequence.
Is it possible in Hibernate to generate this sequence value automatically by Hibernate?
I would be glad to use something like this (but this code doesn't work :( ):
Code:
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="feesSeqnoGenerator")
@SequenceGenerator(name="feesSeqnoGenerator", sequenceName="MAX_FEES_SEQ", allocationSize=1)
@Column(name="SEQNO", nullable=false, precision=18, scale=0)
public long getSeqNo()
{
return seqNo;
}
Any ideas?
Take care,
Adam