-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL query using custom types with multiple columns
PostPosted: Fri Mar 10, 2006 7:19 pm 
Beginner
Beginner

Joined: Wed May 05, 2004 12:45 pm
Posts: 21
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi,

I have my own user defined types that that get mapped to multiple columns. Example
<property name="myProp" type="MyCustomType">
<column name="FIRST_COLUMN"/>
<column name="SECOND_COLUMN"/>

In a HQL query how can I specify to which column I am referring to, without specifying the column name. Is there a syntax that will allow me to specify which column I am referring to. For example myFeature.myProp[0]

Thanks,


Top
 Profile  
 
 Post subject: The names come from your CustomType definition
PostPosted: Fri Mar 10, 2006 10:11 pm 
Beginner
Beginner

Joined: Mon Mar 14, 2005 6:07 pm
Posts: 36
I assume that your user type implements CompositeUserType. Look at the getPropertyNames() method - it returns the logical names of "sub-properties" inside your custom type. Use these names to refer to the elements of the composite type. For example, if your custom type returns {"myField1", "myField2"}, and you map it like you said in your post, then you refer to them as myProp.myField1 and myProp.myField2 in HQL.

I hope this helps.


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