-->
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: SQL query on entity mapped using joined-subclass
PostPosted: Wed Aug 02, 2006 3:14 am 
Newbie

Joined: Wed Aug 02, 2006 2:58 am
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3

Mapping documents:
<hibernate-mapping>
<class name="entity.Program"
table="program"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="programId"
column="program_id"
type="java.lang.Integer"
>
<joined-subclass
name="entity.Seminar"
table="seminar"
>
<key
column="seminar_id"
/>
......./>

My question is if I want to retreive the Seminar entity using a SQL Query what will the query look like? How will I set the SQLQuery.addEntity and do I need to set SQLQuery.addJoin and how?

Thank you in advance.

Imran


Top
 Profile  
 
 Post subject: RE: SQL query on entity mapped using joined-subclass
PostPosted: Wed Aug 02, 2006 10:44 pm 
Newbie

Joined: Wed Aug 02, 2006 2:58 am
Posts: 7
Since nobody is replying I felt necessary to explain the scenario further.

I have a Class called Seminar and Seminar extends Program. I guess HBM file specifies that.

Now when I write SQL for example:

select {seminar.*} from seminar as {seminar}

and from DAO layer I do the following

SQLQuery query = session.createSQLQuery
("select {seminar.*} from seminar as {seminar}");
query.addEntity("seminar", Seminar.class);

hibernate generates the sql with all the property of Seminar and Program where as Program in not in the query it self. So I modified the query to

select {seminar.*}, {program.*} from seminar as {seminar} inner join program as {program} on seminar.id = program.id

Then I hade to add to the query either another entity or join. My understanding is that it should be addJoin but what would be the path, thats simply what I could not figure.
SQLQuery query = session.createSQLQuery
("select {seminar.*} from seminar as {seminar}");
query.addEntity("seminar", Seminar.class);
query.addJoin("program", "path_required_here");


The only possible thing I could guess is that path could be "this". Did not get the time to try but will soon.

Anyways, someone please help its urgent.

Thank you in advance.


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.