• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Hibernate Criteria Query Problem  RSS feed

 
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
 
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!