Hello.
I have problem with mapping table without primary key. My table has two columns witch must have unique vale so in fact they are my primary key, booth columns are date type.
In class which mapping table I put annotation @Id on booth properties (validFrom and validTo).
e.g.
Code:
public class MyTable {
@Id
@Temporal( TemporalType.DATE)
@Column(name="TOSD_VALID_FROM", nullable=false)
private Date validFrom;
@Id
@Temporal( TemporalType.DATE)
@Column(name="TOSD_VALID_TO", nullable=false)
private Date validTo;
..... other fields
}
Now I have two problems:
1. When I loading data e.q. "select u from MyTable u" I haven’t value for second column marked as primary key only first have value (of course value is in table).
2. When I wan to save data only value for first field is sending to DB which cause exception because id can't be null
Hibernate 3.2.4.sp1