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?