-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with Projections.property and CompositeUserType
PostPosted: Mon Sep 18, 2006 2:32 pm 
Newbie

Joined: Fri Jan 27, 2006 2:09 pm
Posts: 14
Hi,

I have a problem using Projections.property in a Criteria.
My property is named value and is a CompositeUserType (BigDecimal + Currency). The columns in the db are value_v and value_c .
Is it possible to use this kind of Projection (PropertyProjection) here?

Greetings Stefan

Hibernate version: 3.1.2

Full stack trace of any exception that occurs:
property does not map to a single column: value


Top
 Profile  
 
 Post subject: same problem
PostPosted: Mon Oct 30, 2006 1:50 pm 
Newbie

Joined: Thu Nov 10, 2005 6:05 am
Posts: 16
Hi Stefan,

I'm currently facing the same problem, have you found any solution to it?

rgrds,
Ivan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 2:07 pm 
Newbie

Joined: Fri Jan 27, 2006 2:09 pm
Posts: 14
Hi Ivan,

I solved the problem this way:

Code:
try {
         final Criteria criteria = HibernateUtil.getSession().createCriteria(IContract.class);
         ProjectionList projections = Projections.projectionList();
         projections.add(Projections.property("value.value"));
         projections.add(Projections.property("value.currency"));
         criteria.setProjection(projections);
         return criteria.list();
      } catch (HibernateException he) {
         throw new FinderException(he.getMessage(), he);
      }


This way I receive Tuples of BigDecimal and Currency. Then you can use a ResultTransformer to transform it into whatever you want.

I hope this is helpful.

Greetings,
Stefan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 5:21 am 
Newbie

Joined: Thu Nov 10, 2005 6:05 am
Posts: 16
Hi Stefan,

thx for the quick answer. unfortunately this isn't a solution to my problem, because I want do write a more dynamic model. I mean the user selects in runtime which properties he wants to see (some kind of dynamic filter)
eg. there is MyPerson which has an Earning field which is a Money UserType (BigDecimal and Currency). And the user can choose whether he wants to see or not the earnings of the person. so the projected properties aren't hardwired in the code.
i'm wondering why can't Hibernate convert the multi-columned UserTypes to the appropriate class in projections while this works with criterias.

regards,
Ivan


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