-->
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.  [ 2 posts ] 
Author Message
 Post subject: Report Queries vs Entity Retirieval and Returning in DTO[]
PostPosted: Sun Mar 04, 2007 6:17 pm 
Newbie

Joined: Tue Dec 19, 2006 3:02 pm
Posts: 4
I think this scenario is interesting and I would assume is used in many applications so it would be nice to hear some opinions...

1.
Using Hibernate 3.2.2 (latest as of this writing), we have an application that does only read-only retrieval of data and has absolutely no persistent requirements at all. What I'd like to do is retrieve an array of various DTO objects (for type safety as we're not on EE 5 yet and hence can't utilize generics yet) through named queries (each sql statement is already done and has over 10 various inner and left outer joins) and simply populate the DTO objects with necessay information to be used by the views. The sql needs to be a native sql and not HQL/JP.

One way is to simply use:
<sql-query name="getSomething">
<return alias="s" class="Something"/>

Although I'm not sure how you tell Hibernate that these are not persistent entities and thus I don't need any dirty checking...class Something is merely a DTO.

Another way is to may be use the reporting queries although it seems that it's only supported by HQL queries using the NEW keyword in the sql.

2.
If anyone also has any thoughts on how to easily transform a collection (List) that you get back from a named query into an array of DTO objects as in Something[], that would be great. I looked into implementing the ResultTransformer, but can't seem to find information without hardcoding the DTO class name. Each query needs to transform into a specific DTO array. I have over 10 various DTO types.

If anyone has any opinions on the two aforementioned issues, I'd be greatful and I'm sure others will be as well.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 05, 2007 5:51 pm 
Newbie

Joined: Tue Dec 19, 2006 3:02 pm
Posts: 4
bump


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.