Hello all,
I want to set a generated value into a relationship table.
This relationship table (named custodian) contains 3 columns:
ID,CUSTODIANDATA_ID and MANDANT_ID
The relationship between the tables is defined like this:
Code:
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinTable(
name = "Custodian",
joinColumns = {@JoinColumn(name = "custodiandata_id", referencedColumnName = "id") },
inverseJoinColumns = { @JoinColumn(name = "mandant_id", referencedColumnName = "id") })
@Column(nullable = false)
private List<Mandant> mandantList;
After setting up a new mandant into the mandantList Hibernate generates following sql
Code:
Hibernate:
insert
into
Custodian
(custodiandata_id, mandant_id)
values
(?, ?)
[2009.10.16 16:16:40:953|T|org.hibernate.type.LongType ] binding '58441' to parameter: 1
[2009.10.16 16:16:40:953|T|org.hibernate.type.LongType ] binding '1' to parameter: 2
[2009.10.16 16:16:40:968|W|..util.JDBCExceptionReporter ] SQL Error: 1400, SQLState: 23000
[2009.10.16 16:16:40:968|E|..util.JDBCExceptionReporter ] ORA-01400: cannot insert NULL into ("T"."CUSTODIAN"."ID")
Does anybody has an idea how to set this id?
All IDs are generated like this
Code:
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "t_sequence")
@SequenceGenerator(name = "t_sequence", sequenceName = "t_seq")
thx