-->
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: lame mapping problem
PostPosted: Tue Feb 22, 2005 5:57 pm 
Newbie

Joined: Tue Feb 22, 2005 5:23 pm
Posts: 3
Hi

I think my problem is quite simple but have no idea how to handle it.
As a result of hibernate query I want to get collection of objects. Each of them is filled with data taken from several tables. I need this data only for read only purposes. Let's see an example:

There are tables: USER (id, name), ORDER(id,user_id,date)

I want to get a collection of rows, each of them consists of two columns:
order_id, user_name, based on joining above tables.

The problem is that I have only one class that I can use as a container : OrderRow, that has two fields orderId and userName and setters and getters for that fields.

The second assumption is that I don't have mappings for objects User and Order in my hbm file. This is because that tables are filled with data by another application. In my application I only need them for report pupropses. In other words, let's assume sql query:

select o.id as id,u.name as name from ORDER o left join USER u ON o.user_id = u.id

I just want to dynamic fill the OrderRow objects list with data from above query without having mapping for both entity tables ORDER and USER .
I thought it would be possible with hibernate dynamic initialization but in that case I think I have to specify mappings for User and Order entities and create classes (User and Order), but I don't want to. Is there any other possibility???

Thanks

Bartek


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 22, 2005 6:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I don't quite understand your reasoning. In anycase try http://www.hibernate.org/hib_docs/reference/en/html/querysql.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 3:51 am 
Newbie

Joined: Tue Feb 22, 2005 5:23 pm
Posts: 3
Thanks David

Yes , that was my first idea to solve this, but was discarged because of
net.sf.hibernate.MappingException: No persister for MyReportContainer

where MyReportContainer is my report class. It is impossible or very complicated to create mapping for such class because it has to be mapped to several tables. I wrote that I don't want to create mapping . I just wanted trivial solution that will copy data from resultset to list of MyReportContainer objects. I thought it should be possible if the container class has setters and in my sql query I map each column to field.
So the No persister.... excepttion was a bit dissapointing to me, cause I thought the mapping is not neede.

Thanks
Bartek


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.