users@glassfish.java.net

JPA : getting a subset of a list

From: <forums_at_java.net>
Date: Tue, 22 Nov 2011 12:29:13 -0600 (CST)

Hi,

I would like to know if there is a way to retrieve, by default, a subset of
elements of Entities just by using annotations.

Here is the problem :

My data objects are saved in my database, but never deleted. If I need to
delete a row, I need to fill special fields such as deletionTime,
deletionAuthor. Those fields are included in my entity, extending a "header"
object which contains those tags. When I was in J2SE, my queries were all
built with " AND deletionTime IS NULL ".

With JPA, when I need to get a list of elements, I just have to call
data.getElements() ; but here, all the children are retrieved. I only want
"active" objects, by default.

My question is : is there a way to configure JPA using annotations or
something else, in order to retrieve children data responding to
pre-established conditions. I'd like to keep the natural access to those
lists ie accessing them thought objet.getList() in the whole application.

Sorry for my english, I hope you understood me.

Thanks a lot for your suggestions.

Olivier.


--
[Message sent by forum member 'laps']
View Post: http://forums.java.net/node/867100