-->
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: Many To Many object ID problems
PostPosted: Fri Jun 04, 2010 3:27 pm 
Newbie

Joined: Wed Apr 14, 2010 4:33 pm
Posts: 8
Hello,
I am having a problem getting the ID for an object which I cascade. I was wondering is there a cache I am not clearing or a way that I can get my object's ID?

User.java
Code:
....
   @ManyToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE},targetEntity=Permission.class)
   @JoinTable(
            name="tblperm",
            joinColumns=@JoinColumn(name="tblUser_id"),
            inverseJoinColumns=@JoinColumn(name="tblpermid")
         )
   @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.PERSIST})
   public Set<Permission> getUserPermissions()
   {
      return permissions;
   }
...


thank you
Permission.java
Code:

@ManyToMany(mappedBy = "userPerm", targetEntity=User.class)
   public Set<User> getAssignedUsers()
   {
      return users;
   }


In my test code I do
Code:
....
   Permission p = new Permission();
   p.setName("Name");
   ......
   dao.findById(u.getId()).getPermission().getId(); // --> Even though I have saved my permission via the cascade on my
                                                                   // dao the ID is null. If I do a dao.getPermissions() the ID is populated
                                                                  // has anyone seen this before?


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.