Hi Berkno Users,
I don't get the reason why I get a NPE when I try to add a user to multiple
groups.
Here is my code snippet:
String groupName = "group1";
GroupImpl group1 = (GroupImpl) groupDAO.getGroupByName(groupName);
if ( group1 == null) {
group1 = (GroupImpl) groupDAO.newGroup(groupName);
groupDAO.addProperty(dspGroup.getGroupId(), "prop-1", "prop-1-v");
groupDAO.addProperty(dspGroup.getGroupId(), "prop-2", "prop-2-v");
}
// The following group exists for sure.
GroupImpl group2 = (GroupImpl) groupDAO.getGroupByName("group2");
// Create the user
try {
User newUser = userDAO.newUser(user.getUserName(), getPassword(),
user.getEmail(), user.getFullName());
// ***** NPE OCCURS HERE *****
userDAO.addToGroup(newUser.getUserId(), group1.getGroupId());
userDAO.addToGroup(newUser.getUserId(), group2.getGroupId());
} catch (DuplicateUserException e) {
throw new IllegalStateException("Duplicated user");
}
Do you have any idea why I get this NPE ?
Just before the call to the line which is causing the exception, you can see
that group1.getGroupId and newUser.getUserId are not null...
I think this is hibernate related... but I don't know enough hibernate to
investigate alone.
As far as I investigated, the issue could be around the assignment of group1.
Thanks for your help,
Fred.
*DISCLAIMER*
This e-mail (including any attachments) may contain information which is privileged or confidential or constitute non-public information.It is to be conveyed only to the intended recipient(s).If you received this e-mail in error, please notify the sender immediately by e-mail or telephone and delete the e-mail from your system without reading, copying or disclosing its contents to any other person.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email