-->
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: partial object, doable or not ? Advice or idea needed
PostPosted: Mon Aug 03, 2009 8:18 am 
Newbie

Joined: Mon Aug 03, 2009 8:05 am
Posts: 1
Hi,

I would like to get back partially valuated object form DB.
Say I want a Person instance but without all its attributes valuated.
Some attributes (valuated or not) may be simple @Basic, but may also be relation like @ManyToOne, ...
This is like in plain old SQL where one try to get only useful columns rather than Select * but this is also a
way to accept or "cut" relations to restrict what come back from DB.

The only way I found to do that is using request and give the list of wanted only attributes after the SELECT
or using Criteria query API.

Unfortunately, in both cases, I get back with an array of hash tables instead of a List<Person>.

Very important note : this should be dynamic and then, can't rely on annotation.
That's why I can't use eager or lazy loading feature to do that, because lazy loading is static.
If you tag eager or lazy one field, not only this will be "forever" but also doesn't make sense for @Basic fields.
There is a solution with query than involve constructor but it is not possible : constructors are not dynamic.
Basically, depending on business rules and end user behavior, I want the Person with only name and first name,
then for another user, I want Person with name, first name and all addresses, then ...
All that happen at run-time.
I can build the query string at run-time without problem, but I can't build a constructor at run-time,
and also I can't develop all the constructors combination !

Question 1 : is it doable ?

Question 2 : is there other solutions ?

The problem I have with hash tables is that all meta information are gone.
I might be able to deal (with some heavy works) with hash table where the key is the attribute name,
but provided hash tables keys are the position inside the SELECT clause.

Thanks for your help!


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.