Hibernate HQL-where question

I am using hibernate at the moment and defining some functions to retrieve specific values from the database.

Now I wanted to change something like this:

User user =new User();

user.setUserId( 1);

user = session.createQuery("from User u where u.userId = '"+user.getUserId()+"'").uniqueResult();

to:

User user =new User();

user.setUserId( 1);

user = session.createQuery("from User u where u = '"+user+"'").uniqueResult();

But this does not work (the first one works fine), i hoped that it would look through the mapping file to check what is the main identifier for the class, and retrieve the values based on that.

Is this possible in any other way, or is this not (yet) implemented?

[924 byte] By [radicjesa] at [2007-11-27 2:35:19]
# 1
noone knows?i understand the hibernate forums are a better place to ask but not registered there :)
radicjesa at 2007-7-12 2:53:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
This isn't possible with HQL. HQL is just plain SQL in a little other format.You may find the objectoriented Criteria Queries useful. See Hibernate Reference Documentation chapter 15.
BalusCa at 2007-7-12 2:53:33 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...