-->
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: Support for Criteria's on collections of value types
PostPosted: Thu Jun 09, 2005 4:50 am 
Newbie

Joined: Thu Jun 09, 2005 4:09 am
Posts: 3
In this post to the Hibernate forum, Gavin stated that there's no support for collections of value types in the Criteria API right now:

http://forum.hibernate.org/viewtopic.php?t=931999

As almost 2 years have passed by by now, this limitation still seems to be valid. Imagine the following mapping scenario:

Code:
<hibernate-mapping>

   <class name="com.kesselheim.hibernatedemo.Project" table="PROJECTS">

      <id name="id" column="IdProject" type="java.lang.Integer">
         <generator class="native"/>
      </id>

               ... other properties go here...

      <set name="members" table="MEMBERS" lazy="false"
         cascade="save-update">
         <cache usage="read-write" />
         <key column="IdProject" foreign-key="fk_member_project" />
         <element type="com.kesselheim.hibernatedemo.LDAPPerson">
            <column name="IdPerson" />
            <column name="LDAPDistinguishedName" />
         </element>
      </set>

   </class>

</hibernate-mapping>


The LDAPPerson type will then transparently "map in" all external data (e.g. name, address, etc.) as provided by the LDAP backend. Nevertheless, the entity relationship is not affected by this "seperation of concern" between hibernate and LDAP:

Code:
       n         n
Project<--------->Person
            |
          member


If I now want to query for all projects that person A takes part in, I can simple use a HQL query such as

Code:
from com.kesselheim.hibernatedemo.Project as project left join fetch project.members as member where member.id = ? and project.status = ?


Unfortunately, with both criterias and filters, it's not that easy. Calling Criteria.createAlias("members") results in a Hibernate exception beeing thrown, stating that the collection did not contain entity types. Same for property expressions and all the other stuff listed in the Hibernate docs.

Relying on HQL queries only becomes difficult on those occasions were really fancy query screens come into play, with lots of optional criterias and stuff. Hence, in order to prevent your application from committing string concatination suicide, it'ld be actually very helpful if one could rely on good old Criteria API.

What do you think? Did I miss something?

Best regards,

Chris


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.