Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using views in JPA / Hibernate

843830Jun 23 2008 — edited Jun 24 2008
Hello

I recently started to work with JPA and hibernate. I have this problem:

In my database, I have table named MyTable. In java source code, I have java class MyClass mapped to this table by JPA annotations @Entity(name="MyTable"). There are many tables in relation with this MyTable so I wrote a view V_MyTable to make it simple to work with it. This view has all MyTable columns, also another columns from joined tables and columns calculated with conditional expressions. Those joined and special columns are annotated not to include in insert and updates (@Column editable,insertable fields).

To keep it simple I would like to use this class mapping for selecting from table and also for inserting/updating/deleting. Is there any way to tell EntityManager that it should include "V_MyTable" (view name) in generated select but in other statements (for example update) "MyTable" (actual table name)?

Thank you for any advices.

Regards

jUmP3r
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2008
Added on Jun 23 2008
1 comment
533 views