-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HQL beginners question
PostPosted: Wed Jan 14, 2004 5:20 am 
Newbie

Joined: Wed Jan 14, 2004 5:10 am
Posts: 4
hello!

sorry for this stupid dump question but iot seems like someone stand on the line here -:)

i have a table users and a class user for it, mapping is all fine and working.

now i want to find a user with the given password and username in my table.

in sql it is something like that :

select * from users where username='xxx' and password = 'xxxxx'

how to do this in HQL?

iam able to do some select * from users in HQL allready ( my first day in hibernate :-) but i dont want all users but the one with the pw and name......

thx


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 14, 2004 5:34 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Please refer to the manual - this is basic HQL.

Code:
List results = session.createQuery(
    "from User user where user.username = :username " +
    "and user.password = :password)
  .setString("password", password)
  .setString("userName", username)
   .list()


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.