-->
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: Composite ManyToOne mapping
PostPosted: Wed Dec 01, 2010 4:33 pm 
Newbie

Joined: Tue Jan 16, 2007 3:44 pm
Posts: 10
Hi everybody,

I am facing some problem from composite ManyToOne mapping below. The codes have no problem for compiling, but I got nothing from the SQLs below. Anybody can help me check whether the mapping models have some problem. I do appreciate it. Happy holiday for everybody! (Hibernate 3.3.1)

select distinct ppr from PersonProjectRole ppr where ppr.parent.person.id =:personId and ppr.parent.project.id =:projectId

Code:
public class PersonProject implements Serializable {

   @EmbeddedId
   private PersonProjectPK pk;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "PERSON_ID", insertable = false, updatable = false)
   private Person person;
   
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "PROJECT_ID", insertable = false, updatable = false)
   private Project project;
   
   @OneToMany(mappedBy="parent", cascade=CascadeType.ALL, fetch=FetchType.LAZY)
   @IndexColumn(name = "ROLE_ID", base = 0)
   private List<PersonProjectRole> roles;
   
   ....
}

@Embeddable
public class PersonProjectPK implements Serializable {
   
   private Long personId;
   private Long projectId;
   ...
}
   
   
public class PersonProjectRole implements Serializable {
   
   @EmbeddedId
   private PersonProjectRolePK pk;

   @ManyToOne(fetch = FetchType.LAZY)
       @JoinColumns({
           @JoinColumn(name="PERSON_ID", insertable = false, updatable = false),
           @JoinColumn(name="PROJECT_ID", insertable = false, updatable = false)
       })
   private PersonProject parent;
   
   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "ROLE_ID", insertable = false, updatable = false)
   private Role role;
   

}

@Embeddable
public class PersonProjectRolePK implements Serializable {

   private Long personId;
   private Long projectId;
   private Long roleId;
   ...
}


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.