-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: One to many relationship from entity to list of value object
PostPosted: Fri Aug 08, 2008 4:36 am 
Newbie

Joined: Fri Aug 08, 2008 3:14 am
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.