I've got to persist an object of class A.
Class A has a lot (10+) many-to-one relationships to other classes.
Before persisting A I need to find out whether a particular instance of A already exists in the database.
If so, I need to update it, if not, I need to create a new instance.
Because the table to which A is mapped has a lot of rows (millions) and A has a lot of foreign keys to the relating tables I thought using a view to quickly retrieve an existing instance of A.
Questions are: - Can I use the same class A and map it both directly to the table and to the view ? - If not, I need to classes I guess, class A and class AView where AView is mapped to the view. - How can I retrieve AView from the view and then update it so that the updates "appear" in the table class A is mapped to ? So I want to retrieve the object via the view, and update it via the table mapping.
Thanks, EDH
|