I have searched StackOverflow for some time now, but have not been successful so far.
Thus creating this Question…
I am currently using JPA, but I have come across a problem (at least, for me it is). Here is the situation:
I have created a system in which a user can be removed, though not removed from the database (for the sake of holding on to the orders of this particular user). For this to work, I have simply added a boolean to the Entity User. All good so far, but here comes the tricky part. As the usage of the system does not require any ‘removed’ users, I do not want to retreive them from the Database.
Is there any way to add a statement of some kind to the @Entity annotation? Or shouldn’t I be using @Entity at all, in this case?
Thanks in advance for the help!
PS. I am not looking for a solution in which I would have to create an User_OLD table of some kind.
First, I suggest renaming column “removed” to “inactive”, because you do not remove user.
For retrieving entities, there are two choices here:
change your @Entity to use USER_ACTIVE view.
If you have Entity, which holds Collection of Users, which is annotated with @FetchType.LAZY: