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-07-2008, 05:01 PM
Member
 
Join Date: May 2008
Posts: 3
ibjava is on a distinguished road
How to get object from composite-id in Hibernate?
Hi all, im new here, and newbie in java also

I usually get an object using id, which that id as the only PK, just like this:
Deposito deposito = dao.getDeposito(depositoId);

but now my Deposito doesn't allow to have id field, and have multiple PKs, here's the hbm code snipplet:
<composite-id>
<key-many-to-one name="dimTime" column="TIME_KEY"/>
<key-many-to-one name="dimLocation" column="LOCATION_KEY"/>
<key-property name="accountNumber" column="ACCOUNT_NUMBER" length="7"/>
</composite-id>

my question is:
How to get object that have composite-id in Hibernate?

actually i want to ask this question in this thread, I got it from google search, but im affraid it's gonna be OOT.

so, please help me & thanx b4!!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-07-2008, 05:05 PM
Member
 
Join Date: May 2008
Posts: 3
ibjava is on a distinguished road
sorry, i forget to show the code for getting Deposito in one id, here's my code:

public Deposito getDeposito(Long id) {
Deposito deposito = (Deposito) getHibernateTemplate().get(Deposito.class, id);
if (deposito == null) {
throw new ObjectRetrievalFailureException(Deposito.class, id);
}
return deposito;
}

Im not change it yet, but now I got trouble to get it with many PK.
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
composite-id problem hibernate javadev Database 13 01-28-2008 09:12 AM
SWT Composite JavaForums Java Blogs 0 12-31-2007 05:53 PM
composite key Hibernate Problem Web Frameworks 0 07-25-2007 12:13 PM
org.hibernate.ejb.Version <clinit> INFO: Hibernate EntityManager 3.2.0.CR1 Heather Database 2 06-30-2007 04:01 PM
composite-id and hibernate Marty Database 1 05-28-2007 05:34 AM


All times are GMT +3. The time now is 09:43 AM.


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