-->
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: Query class mapped with associatino of type <any>
PostPosted: Sun May 06, 2007 12:45 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 10:42 am
Posts: 23
Hi all,

I am trying to execute a query, using the criteria API, on a class that has an association mapped using the <any> mapping.

Here is the relevant part of the hbm.xml:

Code:
<class name="Site" table="SIS_NN_SITE_T">
...
<any name="parent" id-type="string" meta-type="integer">
         <meta-value class="SiteGroup" value="1" />
         <meta-value class="Domain" value="2" />
         <column name="SITE_PARENT_TYPE" />
         <column name="SITE_PARENT_ID" />
      </any>
...



Here is the Java code for the query:

Code:

criteria.createAlias("parent", "parentSite");

criteria.add(Expression.like("parentSite.siteInfo.name", "%" + siteName + "%").ignoreCase());



I get this exception:
Code:

java.lang.UnsupportedOperationException: any types do not have a unique referenced persister

      at org.hibernate.type.AnyType.getAssociatedEntityName(AnyType.java:322)

      at org.hibernate.loader.criteria.CriteriaQueryTranslator.getPathEntityName(CriteriaQueryTranslator.java:207)

      at org.hibernate.loader.criteria.CriteriaQueryTranslator.createCriteriaEntityNameMap(CriteriaQueryTranslator.java:191)

      at org.hibernate.loader.criteria.CriteriaQueryTranslator.<init>(CriteriaQueryTranslator.java:81)

      at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:58)



Now, I think I understand the exception: Hibernate can't know from which table to query (in fact, it should query both "siteGroups" and "domains" tables).

This is understandable. My question, therefore, is how can I perform such a query? Is there any way to do a query on ALL tables associated via the <any> element?

Thanks,
Naaman


Top
 Profile  
 
 Post subject: Re: Query class mapped with associatino of type <any>
PostPosted: Mon May 09, 2011 9:45 am 
Newbie

Joined: Mon May 09, 2011 8:37 am
Posts: 3
Hi, Were you able to find any resolution for this problem?


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.