-->
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.  [ 4 posts ] 
Author Message
 Post subject: HQL Query Issue
PostPosted: Fri Apr 28, 2006 1:49 pm 
Newbie

Joined: Tue Dec 27, 2005 2:55 pm
Posts: 18
Hello everybody!

I just want to make a quit question:

In my DB I have a table Sensor which is connected 1--* with table Parameter (1 Sensor has * Parameters).
I have a value that is a SensorId of table Sensor and I want to get the value of ParameterId in table Parameter, which has the foreign key ID_Sensor.

I'd like to know you is like the HQL query for this kind of select. That is get an Id field of a table starting from an Id field of another table that are connected by a Foreign key of the last table.

Thanks in advance!

P.S: if you know other (better) ways to do this, plz post!


Top
 Profile  
 
 Post subject: Re: HQL Query Issue
PostPosted: Fri Apr 28, 2006 2:14 pm 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
[quote="ivorelvas"]Hello everybody!

I just want to make a quit question:

In my DB I have a table Sensor which is connected 1--* with table Parameter (1 Sensor has * Parameters).
I have a value that is a SensorId of table Sensor and I want to get the value of ParameterId in table Parameter, which has the foreign key ID_Sensor.

I'd like to know you is like the HQL query for this kind of select. That is get an Id field of a table starting from an Id field of another table that are connected by a Foreign key of the last table.

Thanks in advance!

P.S: if you know other (better) ways to do this, plz post![/quote]

Hello Friend:

Can you post ur ona sample? Because, for me is very hard to understand your main idea. Please.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 28, 2006 2:39 pm 
Beginner
Beginner

Joined: Wed Apr 05, 2006 3:19 pm
Posts: 43
List<Parameter> parametersWithSomeSensor = session.createQuery("from Parameters where ID_sensor = ?").setParameter(parameternumber, someSensor.getID()).list();

parameternumber is zero or one, I'm not sure whether it's zero-based or not.

_________________
Don't forget to rate my post if it helped. :)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 29, 2006 5:47 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 3:44 am
Posts: 32
Define an association 1-M between sensor and parameter.....

use your primary - foreign key relation between two tables

then you can use join queries using HQL to get the values you wanted.

For e.g , you can refer Hibernate ref doc


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