-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate and tabular data
PostPosted: Wed Jul 14, 2004 3:40 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
Just wondering what people are doing to return tabular data in web apps or apps for that matter . What I mean by tabular data is data that is not a domain specific object but more a combination of information that you would find in several objects ... the equivalant of doing a join in sql to several tables ? We are using this in our web pages to display lists of items that have alot "joined information" but don't correspond directly to a domain object. Are people just creating objects with properties to hold these values ? Is there some sort of rowset to return tabular data built into hibernate ? I am currently using an hql query that joins serveral objects and have created objects with properties to hold these results. Just wondering what others are doing.

Thanks
Serge


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 14, 2004 4:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Have you tried:

Code:
  select x.name, x.age, y.weight, y.coffe from Person as x, Cup as y


which returns an Object[] with the scalar values

or

Code:
  select new MyValue(x.name, x.age, y.weight, y.coffe) from Person as x, Cup as y


which simply returns a list of MyValue instances (which won't be persistent - but simply a dataholder)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 2:04 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
This is exactly what I am doing .. however in "Hibernate in Action" and "Ejb development without ejb" they seem to frown upon "DTO style" objects .. objects without responsibilities and are just dataholders (Obviously used different in the context of ejb). Taking this into consideration then your the object[] would probably be best but then the UI developer would have to see the hql query in order to determine the order of the information in the object[] . Are others are creating object to hold "row style data" with no real responsibility but to shuttle this data to the UI ? I have no problem with this solution but would like to know if that's what other people are doing aswell.

Thanks again
Serge


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 2:09 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
in fact the anti pattern is "send DTO to UI when you can use the POJO themselves".
Why don't you initialized the part of the graph you need and then "inject" it to the jsp?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 2:26 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 10:58 am
Posts: 43
I suppose I could do that but the some of the graphs are extremly long or conversly the data is not available in the graph I am using. I need more of a "join style list" to aggregate the data I need which might bring us back to the first solution.


Top
 Profile  
 
 Post subject: Bad Solution, but solution at least
PostPosted: Fri Aug 19, 2005 5:55 pm 
Newbie

Joined: Mon Aug 15, 2005 7:53 pm
Posts: 8
Location: Córdoba, Argentina
sboulay, I had the same problem as you. Specifically, I had an object that represents a datagrid... it takes a resultset and prints the table with the columns you set. You can set the columns to show either by column index or column alias.
The problem was that we can't use the datagrids with the "resultsets" (List) that hibernate generates.
When hibernate returns a POJO, no problem, I could use the properties name. But when it was an Object[], we can't do that.
So I made a ResultSet class that takes the results from hibernate, checks if it's a List of POJO or a Object[], and stores a Map with Column Alias / Value Alias. I take the aliases with getReturnAliases().

Now, the problem I'm having is "csating" scalar hibernate result (only one column) to my resultset. I think hibernate returns no alias in this case, just a String or Integer...
I'll try to figure it out

I hope this helps.

Regards,
Matías


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 20, 2005 3:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
H3 now supports returning the alias names as long as your provide the aliases in the query

_________________
Max
Don't forget to rate


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