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: Simple JOIN question
PostPosted: Fri Aug 04, 2006 12:17 pm 
Newbie

Joined: Wed Aug 02, 2006 2:06 pm
Posts: 3
Location: Moorestown, NJ
For a 1-to-1 relationship involving a table of messages, and a table of sources, one message per source, and one source per message.
The MsgDTO is the class that maps to the Msg table.
The SourceDTO maps to the Source table with MsgID being the foreign key.

In the DAO I have

Criteria criteria = session.createCriteria(MsgDTO.class)
.setFetchMode("MsgID", FetchMode.JOIN);
List msgList = criteria.list();

The list should have the results of the join.
How do I get the result set into an array?
Do I create a 3rd DTO called MSDTO that contains a superset of all the fields in the two tables?

This does not work because I get an ArrayStoreException in the 2nd line here.

MSDTOArray msDTOArray = new MSDTOArray();
MSDTO[] ms = (MSDTO[]) msgList.toArray(new MSDTO[0]);


I don't know how to get the joined result set into an array.
Your help is greatly appreciated.

_________________
Glenn Gifford


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 05, 2006 4:46 pm 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
Nope,

The result would be a list of MsgDTOs which aare associated with proper SourceDTOs.

By the way I believe you must change your code to this:

Code:
Criteria criteria = session.createCriteria(MsgDTO.class)
     .setFetchMode("SrcID", FetchMode.JOIN);
List msgList = criteria.list();

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 08, 2006 9:16 am 
Newbie

Joined: Wed Aug 02, 2006 2:06 pm
Posts: 3
Location: Moorestown, NJ
It does not seem right that the result set would be a list of MsgDTO's when the result set of a join is a superset of both tables.

_________________
Glenn Gifford


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.