-->
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.  [ 3 posts ] 
Author Message
 Post subject: as/400 - reveng - composite-id - hql
PostPosted: Tue Feb 07, 2006 2:48 pm 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
Using the Ant tasks for hibernate tools, I've successfully reverse engineered db2 as/400 flat files (tables).

There are no primary keys. So, what's created in the reveng tasks are "tablename.java" and "tablenameId.java".

tablename.java contains 1 attribute: a tablenameId. TablenameId contains fields for all the column names.

The tablename.hbm.xml documents created have composite-id's which contain all the fields from tablenameId.

Here is the problem:
I'm not sure how to fetch data using the tablename/tablenameId paradigm. Since my mapping file only contains a composite-id with > 100 fields, how can I do something like this in Spring:
Code:
this.hibernateTemplate.find("from Cdpcus customer where customer.cusno IN ('401', '403')");

Can't do this right? Cdpcus.java only has 1 atribute: a CdpcusId... CdpcusId.java has the cusno attribute - but there is no mapping for CdpcusId.java.

Must I fetch only with a fully populated tablenameId like this:
Code:
this.hibernateTemplate.find("from Cdpcus customer where customer.id = a_tablenameId");
That leads to another dead-end question: how do I get a populated tablenameId object.

Thanks for your feedback.


Last edited by jruffin on Tue Feb 07, 2006 6:56 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 6:51 pm 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
After reading 1 million posts :-), all asking the same question: how-to query composite-ids (Components as composite identifiers) with Spring / hql / etc... I'm still in limbo.

Anyone solved this one? Small example?

Thanks in advance.


Top
 Profile  
 
 Post subject: example: how-to query via composite identifier
PostPosted: Wed Feb 08, 2006 12:37 pm 
Regular
Regular

Joined: Sat Nov 06, 2004 5:20 pm
Posts: 54
Location: Collierville, TN
Small example:

Code:
List list =
         this.getHibernateTemplate().find("from Cdpcus cus where cus.id.CUSNO = ?", cusno);
      
      if (list.size() > 0){
         customerData = (Cdpcus)list.get(0);
         System.out.println("customerData.cusno is: " + customerData.getId().toString());


Kinda reminds me of Apple WO EOF. cus.id.CUSNO


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.