-->
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: AliasToBeanResultTransformer alias mapping strategy
PostPosted: Thu Feb 21, 2008 10:58 am 
Newbie

Joined: Thu Feb 21, 2008 10:36 am
Posts: 2
Hi !

I use an AliasToBeanResultTransformer and a ProjectionList on most of my search queries for performance and memory reasons: I don't want to to select all fields of root + joined tables.

The problem is that I need to create a Bean with getters/setters for each selected fields.

Here is an example:

Code:
class PersistantClass1 {
   private string label;
   private PersistantClass2 parent;
   //...dozen of other properties...;
   //getters/setters
}

class PersistantClass2 {
   private String parentLabel;
   private int  parentOrder;
   //...dozen of other properties...;
   //getters/setters
}


I want to select label, parentLabel, parentOrder order by parentLabel

Actually I have to use a ProjectionList

Code:
projectionList.add(Projections.property("label"), "label");
projectionList.add(Projections.property("parent.parentLabel"), "parentLabel");
projectionList.add(Projections.property("parent.parentOrder"), "order");


and create a bean:

Code:
class MyBean {
   private String label;
   private String parentLabel
  private int order;
   //getters and setters
}



Is there a possibility to reuse my Entity to avoid creating a Bean for each query ?
I would use "." in aliases to tell hibernate how the entity is structured to call the .setter.setter....
like this:

Code:
projectionList.add(Projections.property("label"), "label");
projectionList.add(Projections.property("parent.parentLabel"), "parent.parentLabel");
projectionList.add(Projections.property("parent.parentOrder"), "parent.parentOrder");



actually, hibernates complains "parent.parentLabel property not found" .
If it could perform split(".") to find the setters, it would be great !

Did I miss something ?
Is it already possible to do this (without using HQL...I need criteria because of mutiple dynamic where clauses)

Hibernate version:
3.2.5


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.