This week's book giveaway is in the HTML, CSS and JavaScript forum.
We're giving away four copies of hapi.js in Action and have Matt Harrison on-line!
See this thread for details.
Win a copy of hapi.js in Action this week in the HTML, CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate Criteria Query Problem

 
Shifali Rana
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I just want to ask that the following code can add a row in the table. If the logonid doesn't exist in the system then the logonid will give null Or it will create a new row in the table.

Criteria criteria = currentSession.createCriteria(com.test.cs.model.user.User.class);
criteria.add(Restrictions.eq("logonID", logonID));
user = (User)criteria.uniqueResult();

The problem is that initially there is no record in the table for logonid = 1 but on executing the above code it creates an entry in the user table for logonid = 1.

Thanks
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, that code cannot produce a row in a table. It's a query.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!