-->
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: where restriction not propogating to isEmpty criteria expres
PostPosted: Wed Mar 15, 2006 7:56 pm 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
Problem summary:

I have Media objects that have related CrewMemberRel objects. CrewMemberRel objects have a CrewRole type. I want to fetch the CrewMemberRel objects based on the CrewRole type, so the mapping documents have a where clause to switch on the crew role type:

Code:
<set name="talentRels" where="crew_role_id = 1">
    ..
</set>
<set name="producerRels" where="crew_role_id = 2">
    ..
</set>

[full mapping docs below]

This works fine.

The problem is when I want to use an isEmpty Expression from the Criteria API. The HQL that results from that Criteria does not include the where clause restriction in the exists clause:

Code:
(not exists (select 1 from cmsuser.crewmember_role_media_rel where this_.id=media_id))


instead of what I am looking for:

Code:
(not exists (select 1 from cmsuser.crewmember_role_media_rel where this_.id=media_id and crew_role_id = 1))


Is there a better way to model my relationship to get this?

Thanks!

Dan


Java:

Code:
      Criteria criteria = getSession().createCriteria(Media.class);
      Disjunction or = Expression.disjunction();
      or.add(Expression.isEmpty('producerRels'));
                // more experssions
      criteria.add(or);
      criteria.list();




Hibernate version: 3.1.2

Mapping documents:

Code:
   <class name="Media" table="media" where="visible=1">
          <id column="id" name="id" type="long">
              <generator class="native"/>
          </id>
      
      <!-- talent -->
      <set name="talentRels" cascade="save-update" where="crew_role_id = 1">
         <key column="media_id"/>
         <one-to-many class="CrewMemberRoleRel"  />
      </set>

      <!-- producers -->
      <set name="producerRels" cascade="save-update" where="crew_role_id = 2">
         <key column="media_id"/>
         <one-to-many class="CrewMemberRoleRel"  />
      </set>

   </class>   
   
   <class name="CrewMemberRoleRel" table="crewmember_role_pod_rel">

          <id column="id" name="id" type="long">
              <generator class="native"/>
          </id>
      
      <many-to-one name="crewMember" column="crew_member_id" class="CrewMember"/>   
      <many-to-one name="crewRole" column="crew_role_id" class="CrewRole"/>   
      <many-to-one name="media" column="media_id" class="Media"/>   
      
   </class>




Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 26, 2007 8:17 pm 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
almost a year later, I'd like to bump this up and see if there are any suggestions, or maybe an upgrade would fix my problem. I am currently using 3.1.3.

Thank you!

_________________
_________________
dan

If what I say is helpful, please rate the post as such by clicking 'Y'. I appreciate it.


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.