I have an EmbeddedId class which consists of 4 columns. 3 of these columns are assigned values while the fourth column should be value retrieved from a sequence table.
Code:
@Embeddable
public class DistributionId extends DirectId {
private static final long serialVersionUID = -1693326833940025204L;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CDDT_PART_GRP_ID")
private Integer groupId;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CDDT_CUST_AGR_ID")
private Integer agreementSequenceNumber;
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CDDT_MSG_TYP_ID")
private Integer messageTypeId;
@TableGenerator(
name = "CDDT_SEQ_GEN",
table = "SEQ_NUMBER",
pkColumnName = "SEQN_COLUMN_NAME",
valueColumnName = "SEQN_NUMBER",
pkColumnValue = "CDDT_CDDT_SEQ",
allocationSize = 1
)
@GeneratedValue(strategy = GenerationType.TABLE, generator = "CDDT_SEQ_GEN")
@Column(name = "CDDT_CDDT_SEQ")
private Integer distributionSequence;
I am using a TableGenerator on another class with only one Id and that one works fine. How can I get the generator to retrieve a new value from the database table and use the other as assigned?
I am using Hibernate version 3.3.1 and this has support for a generator on a single composite-key. How can I get this to work with Annotations?