-->
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: Use Map objects in passing parameters for a named HQL query
PostPosted: Sat Nov 18, 2006 10:10 am 
Newbie

Joined: Sat Nov 18, 2006 10:03 am
Posts: 3
Hi!
I'm writing an HQL query like this

Code:
from SomeObject as a
where a.someProperty = :someProperty
AND a.someProperty2 = :someProperty2


and I set the parameters doing

Code:
query.setProperties(param)


where the "param" object is of type SomeObject, and has the method getSomeProperty:
hibernate bind the named parameters in the query with the property of the object
I pass throug setProperties()...
Everything works, ok.

Now the question: is it another method to pass an arbitrary number of parameters
(with arbitrary names) to the query??
I mean, I don't want to pass an object of the type SomeObject, but - I guess - a
Map with some entries, which has the keys "someProperty" and "someProperty2"...
It seems not to work!

(I ask this because my SomeObject has some fields that are objects with their own fields,
i.e.: if SomeObject.someProperty is an object with two properties, prop1 and prop2,
and I want to write a "where" condition like

Code:
where a.someProperty.prop1 = :someProperty.prop1


I mean, using only a subset of all the properties mapped for the someProperty
object..
)

thank you everybody for helps and suggestions!!
A.


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.