I am facing very strange problem.
My Search Command is in transaction context,
The search result has one to many relation ships
Like User ----> UserPermission
Hibernate get all Users and its Permission,
Immediately it clears the Permissions for the user
Since this is in transaction context,
It also removes the permission from table.
Please help me to understand this problem and resolve it.
why hibernate clear the permission after it fetch.
Environment.
Hibernate 2.8.1
Jboos 32.6
JDK 1.5
Java code
public class SearchUserCommand extends SearchCommand
{
private List<User> userList = null;
private static Object cat =
SawMill.addCategory(SearchUserCommand.class.getName());
protected void doExec(Session session) throws AccessException
{
SawMill.debug(cat,"Inside doExec() of SearchUserCommand");
Criteria queryCriteria = session.createCriteria(User.class);
Criterion expression = null;
Order newOrder = null;
for(Iterator<Criterion> i = filter.iterator(); i.hasNext(); )
{
expression = i.next();
queryCriteria.add(expression);
}
for(Iterator<Order> i = order.iterator(); i.hasNext(); )
{
newOrder = i.next();
queryCriteria.addOrder(newOrder);
}
try
{
userList = queryCriteria.list();
}
catch(HibernateException ex)
{
SawMill.error(cat,"Can't search user Info : "+ex.getMessage());
throw new AccessException("Error while searching user Info",ex);
}
}
public List<User> getUserList()
{
return userList;
}
}
|