-->
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.  [ 1 post ] 
Author Message
 Post subject: Maping generic SQL to POJO in hibernate
PostPosted: Fri Mar 04, 2005 5:29 pm 
Newbie

Joined: Mon Feb 07, 2005 3:46 pm
Posts: 5
Hibernate version:2.1.7

Mapping documents:
<hibernate-mapping>
<class name="com.gnet.gds.query.category.impl.CategorySearchResultImpl">

<cache usage="read-only"/>

<composite-id>
<key-property name="ProgramType" column="program_type" type="string"/>
<key-property name="programId" column="program_id" type="integer"/>
<key-property name="title" column="program_title" type="string"/>
<key-property name="TVRating" column="tv_rating" type="integer"/>
<key-property name="MPAARating" column="mpaa_rating" type="integer"/>
<key-property name="category" column="category" type="integer"/>
<key-property name="sourceId" column="source_id" type="integer"/>
<key-property name="startTime" column="start_time" type="integer"/>
<key-property name="assetId" column="asset_id" type="string"/>
<key-property name="duration" column="duration" type="string"/>
</composite-id>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:Oracle 10g

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Documentation seems a little thin - task, map a generic sql result set into a pojo using hibernate. The query:

select 'LINEAR' as program_type,
min(p.program_id) as program_id,
ps.long_title as program_title,
p.tv_rating,
p.mpaa_rating,
p.category,
min(sch.source_id) as source_id,
min(sch.start_time) as start_time,
null as asset_id,
TO_CHAR(min(sch.duration)) as duration
from program p,
program_string ps,
schedule sch,
service ser
where p.payload_id = :payload_id
and p.CATEGORY = :category_id
and p.payload_id = ser.payload_id
and p.program_id = sch.program_id
and p.program_id = ps.program_id
and ser.HARDWARE_ADDRESS = :hardware_address
and ser.hardware_address = sch.hardware_address
and ser.hardware_address = p.hardware_address
and sch.payload_id = ser.payload_id
and sch.source_id = ser.source_id
and sch.start_time >= :start_time

group by ps.long_title,
p.tv_rating,
p.mpaa_rating,
p.category

I got the arguments in there, and this query (when he arguments are coded to something real) runs in say SQL+ for oracle, but I can not get it to run in Hibernate using the session.createSQLQuery() call.

HELP PLEASE.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.