Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2007, 01:27 AM
Member
 
Join Date: May 2007
Posts: 39
Nick15 is on a distinguished road
Search in hibernate
Hi!
I have a bean defined with the follow properties:
Code:
public class UserTopic implements java.io.Serializable { private UserTopicId id; private Topic topic; private int personal = 0; ------- UserTopicId is: ----------- public class UserTopicId implements java.io.Serializable { private String topicId; private String userId; -----------
Normally, to search topics for an user I did:
getHibernateTemplate().find(" from UserTopic where user_id = ?", user_id)

but I don't know how do I search with this key

Do you know?

thanks

Last edited by Nick15 : 06-01-2007 at 01:15 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-05-2007, 01:55 AM
Member
 
Join Date: May 2007
Posts: 39
Alan is on a distinguished road
hi


try this
getHibernateTemplate().find(" from UserTopic ut where ut.id.userId = ?",
user_id)

bye bye
alan
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-05-2007, 04:55 PM
Member
 
Join Date: May 2007
Posts: 42
Freddie is on a distinguished road
If you have defined the id in the HBM you can do a load:

(key-many-to-one in hibernate 3).

session.load(UserTopic.class, new UserTopicId("id","user");
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-07-2007, 07:20 AM
Senior Member
 
Join Date: Mar 2007
Posts: 136
goldhouse is on a distinguished road
If you are looking for users starting with the given userID you can use the "Criterion" in hibernate .
Like this
Code:
List users = sess.createCriteria(User.class) .add( Restrictions.like("name", userID+"%") ) .list();
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-09-2007, 02:33 PM
Member
 
Join Date: May 2007
Posts: 39
Nick15 is on a distinguished road
thanks you goldhouse! it works
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to search with a Comparator Java Tip java.lang 0 04-15-2008 08:39 PM
Search TextFile gsupriyarao@yahoo.com Advanced Java 5 04-11-2008 12:03 PM
Search Gilgamesh New To Java 5 11-26-2007 04:45 AM
Web Search Marcus Enterprise JavaBeans 2 07-02-2007 07:51 AM
org.hibernate.ejb.Version <clinit> INFO: Hibernate EntityManager 3.2.0.CR1 Heather Database 2 06-30-2007 04:01 PM


All times are GMT +3. The time now is 04:38 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org