-->
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: sql-query syntax problem on object with composite-id
PostPosted: Mon Aug 30, 2004 12:32 pm 
Newbie

Joined: Tue Dec 16, 2003 12:02 pm
Posts: 14
Location: Geneva, Switzerland
Hibernate version:
2.1.1

Mapping documents:
<hibernate-mapping>
<class name="newt.Strain" table="testeditor_strains">
<composite-id name="key" class="newt.StrainKey">
<key-property name="oscode" column="sptr_code" type="string" length="10"></key-property>
<key-property name="name" column="name" type="string" length="255"></key-property>
</composite-id>
<property name="strain" column="strain" type="string" length="255"></property>
<property name="nameclass" column="name_class" type="string" length="50"></property>
</class>
<sql-query name="loadStrainDiff">
select {strain}.sptr_code as {strain.key.oscode},
{strain}.name as {strain.key.name},
{strain}.strain as {strain.strain},
{strain}.name_class as {strain.nameclass}
from strains {strain} EXCEPT
select s.sptr_code,
s.name,
s.strain,
s.name_class
from testeditor_strains
order by {strain.key.oscode} <return alias="strain" class="newt.Strain"/>
</sql-query>
</hibernate-mapping>

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

List results = s.getNamedQuery("loadStrainDiff").list();

Full stack trace of any exception that occurs:

database error: net.sf.hibernate.QueryException: Alias [strain.key] does not correspond to any of the supplied return aliases = {[strain]} [
select {strain}.sptr_code as {strain.key.oscode},
{strain}.name as {strain.key.name},
{strain}.strain as {strain.strain},
{strain}.name_class as {strain.nameclass}
from strains {strain} EXCEPT
select s.sptr_code,
s.name,
s.strain,
s.name_class
from testeditor_strains
order by {strain.key.oscode}
]

I then tried:

<sql-query name="loadStrainDiff">
select {strain}.sptr_code as {strainkey.oscode},
{strain}.name as {strainkey.name},
{strain}.strain as {strain.strain},
{strain}.name_class as {strain.nameclass}
from strains {strain} EXCEPT
select s.sptr_code,
s.name,
s.strain,
s.name_class
from testeditor_strains
order by {strainkey.oscode} <return alias="strain" class="newt.Strain"/>
<return alias="strainkey" class="newt.StrainKey"/>
</sql-query>

and got:
database error: net.sf.hibernate.MappingException: No persister for: newt.StrainKey

Name and version of the database you are using:postgreSQL 7.3.2


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.