-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL question - Multiple tables, return only 1 table and ...
PostPosted: Thu Jun 16, 2005 8:46 am 
Beginner
Beginner

Joined: Wed Nov 17, 2004 11:15 am
Posts: 25
Hi,

I have a mapping-file like this:

Mapping documents:

<?xml version="1.0"?>
...
<hibernate-mapping>
<class name="de.fhkempten.model.sap.Spfli" table="spfli">
<composite-id name="id" class="de.fhkempten.model.sap.SpfliId">
<key-many-to-one name="scarr" class="de.fhkempten.model.sap.Scarr">
<column name="carrid" length="5" />
</key-many-to-one>
<key-property name="connid" type="string">
<column name="connid" length="5" />
</key-property>
</composite-id>
<property name="airpfrom" type="string">
<column name="airpfrom" length="45" not-null="true" />
</property>
...
<set name="sflights" inverse="true">
<key>
<column name="carrid" length="5" not-null="true" />
<column name="connid" length="5" not-null="true" />
</key>
<one-to-many class="de.fhkempten.model.sap.Sflight" />
</set>
</class>
</hibernate-mapping>


My aim is to access the "scarr" column of this table.
Something like "select spfli.scarr from de.fhkempten.model.sap.Spfli as spfli", throws an error: "could not resolve property: scarr".


Anyone got an idea how I can do this?


Thanks
Jonny


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 8:50 am 
Beginner
Beginner

Joined: Wed Nov 17, 2004 11:15 am
Posts: 25
Sorry,

inserted the wrong subject. Will post again as "HQL question - How to access certain keys"

Cheers
Jonny


Top
 Profile  
 
 Post subject: Re: HQL question - Multiple tables, return only 1 table and
PostPosted: Thu Jun 16, 2005 8:50 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
jonnybecker wrote:
Hi,

I have a mapping-file like this:

Mapping documents:

<?xml version="1.0"?>
...
<hibernate-mapping>
<class name="de.fhkempten.model.sap.Spfli" table="spfli">
<composite-id name="id" class="de.fhkempten.model.sap.SpfliId">
<key-many-to-one name="scarr" class="de.fhkempten.model.sap.Scarr">
<column name="carrid" length="5" />
</key-many-to-one>
<key-property name="connid" type="string">
<column name="connid" length="5" />
</key-property>
</composite-id>
<property name="airpfrom" type="string">
<column name="airpfrom" length="45" not-null="true" />
</property>
...
<set name="sflights" inverse="true">
<key>
<column name="carrid" length="5" not-null="true" />
<column name="connid" length="5" not-null="true" />
</key>
<one-to-many class="de.fhkempten.model.sap.Sflight" />
</set>
</class>
</hibernate-mapping>


My aim is to access the "scarr" column of this table.
Something like "select spfli.scarr from de.fhkempten.model.sap.Spfli as spfli", throws an error: "could not resolve property: scarr".


Anyone got an idea how I can do this?


Thanks
Jonny


scarr is not a property of spfli, it's a property of spfli.id so I would think you would access it as spfli.id.scarr ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 8:55 am 
Beginner
Beginner

Joined: Wed Nov 17, 2004 11:15 am
Posts: 25
Thanks for the quick reply. Now its working!!

Thank you very much!! You saved the day

P.S.: If some admin could please change the subjetc of this message to "HQL question - How to access certain keys" (if this wrong subject bothers anyone), how I dummy intended it.

Cheers
Jonny


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 10:26 am 
Beginner
Beginner

Joined: Wed Nov 17, 2004 11:15 am
Posts: 25
One last question:

My mapping-file

<class name="de.fhkempten.model.sap.Sflight" table="sflight">
<composite-id name="id" class="de.fhkempten.model.sap.SflightId">
<key-many-to-one name="spfli" class="de.fhkempten.model.sap.Spfli">
<column name="carrid" length="5" />
<column name="connid" length="5" />
</key-many-to-one>
<key-property name="fldate" type="date">
<column name="fldate" length="10" />
</key-property>
</composite-id>
...


If I do a query like this (to return a single column): "SELECT sf.id.spfli.carrid FROM Sflight sf" I get the following error: "Operand should contain 1 column(s)".

When I do a similar query on the mapping-file posted before, like: "select sp.id.scarr.carrid from Spfli sp" it works (to return this column).

What am I doing wrong now?

Thanks
Jonny


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