Hibernate version: 3
Name and version of the database you are using: Sybase ASE 12.5
For a couple of days I've been trying to map the following object model:
Code:
@Entity
@Table(name="forms2")
public class Form {
@Id
private int id;
@Version
private Long rowVersion;
@CollectionOfElements(fetch=FetchType.EAGER)
@JoinTable(
name="formTranslations",
joinColumns = @JoinColumn(name="formId")
)
@CollectionId(
columns = @Column(name = "id"),
type = @Type(type="integer"),
generator = "identity"
)
private List<FormTranslation> formTranslations = new ArrayList<FormTranslation>();
.....
}
FormTranslation is considered a value object; its lifecycle should be bound to that of its Form.
Code:
@Embeddable
public class FormTranslation {
@Column(name="language")
private String language;
@Column(name="title")
private String title;
@Column(name="summary")
private String summary;
@Column(name="translations")
private String translations;
.....
}
It should be clear that in my model I want to have a unidirectional association between these two objects.
One of my database constraints is that each table containing real data should have a primary key (id) - this applies to the formTranslations table. Furthermore I'd rather not use a link-table.
I was not able to get the @CollectionId's generator (for a surrogate primary key) to play nicely with Sybase's identity. While doing an update (JPA merge) to a form I'm seeing:
Hibernate: update forms2 set formKey=?, formXML=?, rowVersion=? where id=? and rowVersion=?
Hibernate: delete from formTranslations where id=?
Hibernate: insert into formTranslations (formId, id, language, summary, title, translations) values (?, ?, ?, ?, ?, ?)
[IntegerType] could not bind value 'POST_INSERT_INDICATOR' to parameter: 2; org.hibernate.id.IdentifierGeneratorFactory$2
Any ideas why this is happening? Possible solutions/workarounds are more than welcome!