Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes 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