I am trying to solve a problem that has probably been answered more than once, but for the life of me, I cannot find the solution anywhere.
I have a persistent class called item which looks something like what is listed below (though I've left out many of the details for brevity):
@Entity
@Table(name="ITEMS")
public class Item {
@Id
@Column(name="id")
@GeneratedValue
private int id;
@Column("name")
private
String name;
...
}
I have no issues doing any data manipulation of this class via the standard Hibernate methods.
In a
JSF application, I'm going to present a list of Item objects and allow a user to select ones to delete using a checkbox (pretty standard stuff here

).
I want to USE the Item class since it exposes everything I need, with the exception of a boolean flag called "selected." I therefore created a new class as follows (and again, I've left out getters/setters):
public class SelectableItem extends Item {
public boolean isSelected;
...
}
Everything is great until I go to save the SelectableItem class back to the database because Hibernate (naturally) does not have a mapping from SelectableItem into the database. I don't want to put the flag in the base class because I want to keep the Item class separate from the UI (obviously). I also don't want to use composition and then have to expose ALL of the enclosed class's methods. Is there a simple, more elegant, solution to this problem or is what I'm trying to do here "half-baked?"
I hope my explanation was accurate enough and thanks, in advance for any help provided.