-->
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.  [ 6 posts ] 
Author Message
 Post subject: Native SQLQueries and Components
PostPosted: Thu Dec 18, 2003 6:10 am 
Newbie

Joined: Mon Sep 15, 2003 4:37 am
Posts: 6
Location: Frankfurt Germany
Hello,
i have a problem with native SQLQueries and its mapping to components in a Java-Class.
Hibernate throws a net.sf.hibernate.QueryException: Alias [p.address] does not correspond to any of the supplied return aliases = {[p]} .

Can i use components and native SQLQueries together and i am using the wrong syntax (for example: {p.address.zipCode})?

Thanks in advance

Peter K


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 18, 2003 7:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This should work. Max?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 6:05 am 
Newbie

Joined: Mon Sep 15, 2003 4:37 am
Posts: 6
Location: Frankfurt Germany
gavin wrote:
This should work. Max?


Any new Information why there is a problem?


Top
 Profile  
 
 Post subject: Has this problem been fixed?
PostPosted: Thu Jun 17, 2004 1:09 pm 
Newbie

Joined: Thu Jun 17, 2004 1:05 pm
Posts: 2
We are having the same problem regarding the population of components in native SQL queries.

We are using the latest version of Hibernate.

Thanks.


Top
 Profile  
 
 Post subject: Re: Has this problem been fixed?
PostPosted: Fri Jun 18, 2004 3:33 am 
Newbie

Joined: Mon Sep 15, 2003 4:37 am
Posts: 6
Location: Frankfurt Germany
robmiller wrote:
We are having the same problem regarding the population of components in native SQL queries.

We are using the latest version of Hibernate.

Thanks.


We have switched to SQLMaps in the meantime (but not because of this minor bug).

Greetings

Peter K


Top
 Profile  
 
 Post subject: Problem solved...thanks.
PostPosted: Wed Jun 23, 2004 1:36 pm 
Newbie

Joined: Thu Jun 17, 2004 1:05 pm
Posts: 2
Thank you for the SQLMaps suggestion.

To be more specific about our problem, we were trying to map 15 tables to one object and its one nested/child object. We did not want to create objects for each of the 15 tables just so we could do the join in HQL.

Our solution: Instead of writing a native SQL query that mapped nested child objects (which didn't work in Hibernate), we created two materialized views in the database that represented our 15 tables joined together. Then we were able to get it working with Hibernate using HQL:
Code:
parentObject = (ParentObject) dbSession.createQuery("FROM com.foo.ParentObject as parentObject left outer join fetch parentObject.childObject as childObject "
+ "WHERE ...").setString("paramOne", "bar").uniqueResult();


The ParentObject mapped to a materialized view and the ChildObject mapped to another materialized view joined together in the HQL.


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