-->
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: Extended domain with formula-property
PostPosted: Fri Mar 27, 2015 5:44 am 
Newbie

Joined: Wed Nov 12, 2008 2:14 am
Posts: 6
Hi,

I like hibernate formulas in domain property mapping, because they enables
domain filtering/ordering (with formula-property).
On the other hand, this can be resource consuming and in many usecases unnecessary.
So I search pattern, how to permit "caller" determine, if in this
concrete usecase needs or not this formula-properties.

Say we have Person class and extension PersonX with formula-property.
Code:
class Person {
  String name;
  String email;
}
class PersonX extends Person {
  /* online computed value from many other domain/tables info */
  int rating; 
}



Now, I want to determine, if rating property is needed or not.
So I create dao
Code:
public interface PersonDao  <T extends Person> {
     T load (String name);
}


and in code I will write
Code:
PersonDao<Person> dao; 
PersonDao<PersonX> daoX;
Person adam =   dao.load("adam"); // name, email
PersonX adamX = daoX.load("adam"); // name, email, rating


So. I can not find pattern, how arrange it in hibernate mapping.

Code:
<class name="Person" table="PERSON"  dynamic-update="true">
  <property name="name" column="NAME"  />
  <property name="email" column="EMAIL"/>
</class>   


but what for PersonX?? where and how to declare
Code:
  <property name="rating" formula=" (select blabla ... )"/>


I do not want two independency mapping one for Person and second for PersonX.
This is redundant code and not ideal for cache.
Classic hib inheritance depends on discriminator but this is not my case.

Can you please direct me to solution?

Regard
Jara


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.