-->
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.  [ 3 posts ] 
Author Message
 Post subject: Restrictions on fields with UserType question
PostPosted: Fri Jul 21, 2006 12:14 pm 
Beginner
Beginner

Joined: Fri Apr 09, 2004 12:47 pm
Posts: 36
Hi,
this is a pretty much open ended question.
Are UserType columns usable in any meaningful way in both hql or the criteria api?

For example, what if I query a user type that defines a value with a unit, and that's mapped onto two columns on the db, namely value and unit. Would a query like

myUserTypeAttribute > Measure(20,kiloVolt)

be turned into sql as:

value > 20 and unit > 'kilovolt'?

That's what it seems from the the code inside SimpleExpression at least (taken from the Criteria API).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 1:11 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Never tried it in Criteria, but it should work. In HQL, you have to do the opposite:
Code:
myUserTypeAttribute.value > 20 and myUserTypeAttribute.unit = kiloVolt
From section 14.8 of the ref docs:
refdocs wrote:
You may also specify properties of components or composite user types (and of components of components, etc). Never try to use a path-expression that ends in a property of component type (as opposed to a property of a component).

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 24, 2006 3:02 am 
Beginner
Beginner

Joined: Fri Apr 09, 2004 12:47 pm
Posts: 36
tenwit wrote:
Never tried it in Criteria, but it should work. In HQL, you have to do the opposite:
Code:
myUserTypeAttribute.value > 20 and myUserTypeAttribute.unit = kiloVolt
From section 14.8 of the ref docs:
refdocs wrote:
You may also specify properties of components or composite user types (and of components of components, etc). Never try to use a path-expression that ends in a property of component type (as opposed to a property of a component).


Doh, never noticed that paragraph. Thank you for the answer, it's really helpful.


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