Results 1 to 2 of 2
- 05-07-2008, 04:01 PM #1
Member
- Join Date
- May 2008
- Posts
- 3
- Rep Power
- 0
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!!:cool:
- 05-07-2008, 04:05 PM #2
Member
- Join Date
- May 2008
- Posts
- 3
- Rep Power
- 0
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.
Similar Threads
-
composite-id problem hibernate
By javadev in forum JDBCReplies: 14Last Post: 07-27-2009, 06:30 PM -
composite key Hibernate
By Problem in forum Web FrameworksReplies: 0Last Post: 07-25-2007, 11:13 AM -
org.hibernate.ejb.Version <clinit> INFO: Hibernate EntityManager 3.2.0.CR1
By Heather in forum JDBCReplies: 2Last Post: 06-30-2007, 03:01 PM -
composite-id and hibernate
By Marty in forum JDBCReplies: 1Last Post: 05-28-2007, 04:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks