-->
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: any type query
PostPosted: Fri Sep 26, 2008 9:01 am 
Newbie

Joined: Thu Sep 18, 2008 1:05 pm
Posts: 3
Hi I use JBPM, where class VariableInstance has an association to any business object mapped as any type (association is mapped in two columns to db one column is class name, second is id of object). Is it possible to write a query against VariableInstances which reference to business object that meets some criteria? I can write a query using plain sql, because I always know what type by business object (table) it is and what its id is.

I tried to do it this way

//criteria used to select business object
DetachedCriteria dcVariableObject = ...

DetachedCriteria dcVariableInstance = DetachedCriteria.forClass(HibernateLongInstance.class)
.add(Property.forName("value").in(dcVariableObject));

Does not work!
org.hibernate.QueryException: property does not map to a single column: value

Second try


//criteria used to select business object with projection to id
DetachedCriteria dcVariableObject = ... .setProjection(Projections.id());

//ids of business objects meeting criteria
List<Long> dc = dcVariableObject.getExecutableCriteria(session).list();

DetachedCriteria dcVariableInstance = DetachedCriteria.forClass(HibernateLongInstance.class)
.add(Restrictions.sqlRestriction("LONGVALUE_ in ? ", dc, Hibernate.LONG));

Does not work neither! ClassCastException, because there is no type collection/array of long.

Thanks for any help

Fero


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.