0 Replies Latest reply on Jun 1, 2005 11:46 PM by doofus

    Foreign identity generation

    doofus

      I read somewhere that foreign identity generation is not yet implemented. Is this the case?

      For example

       @Entity
       public class Response
       {
       @Id(generate = GeneratorType.IDENTITY)
       int getId()
       { .. }
       @OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER,mappedBy="response")
       Collection<Answer> getAnswers()
       { .. }
       }
      
       @Entity
       public class Answer
       {
       @EmbeddedId({
       @AttributeOverride(name="response"),
       @AttributeOverride(name="question")
       })
       int getId()
       { .. }
      
       String getAnswer()
       { .. }
       }
      
      


      Also, the AnswerPK class would just store 2 int's for the id's. When I try to do this (essentially):

       Response r = new Response();
       r.getAnswers().add(new Answer(..));
       em.persist(r);
      


      I get a constraint error in relation to the foreign key (Answer.id.response).

      Any help would be appreciated. Thanks.