File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Question on JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Question on JPA" Watch "Question on JPA" New topic

Question on JPA

Seetharaman Venkat

Joined: Nov 07, 2010
Posts: 16
1) Could we use non-mapped variables in an Enity Object(which uses JPA annotations)

2) Is there way we could use the Annotation mapping and Call to a Stored procedures in the same entity class?

3) Here is one more scenario
Table mapped to the below two

Now there is a condition: TEST_TABLE3, TEST_TABLE4 hava a column VALUE. And I want all values were TEST_TABLE3.VALUE==TEST_TABLE4.VALUE.
How do I do that? IS there a way to efficiently perform and implement the above three scenarios?

Please let me know, I will appreciate your help.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Is this an interview question? Or an assignment?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Seetharaman Venkat

Joined: Nov 07, 2010
Posts: 16
I am moving from EJB to spring, some legacy code has tedious SQLs (which call stored procedures), using JPA I have succesfully replace the SQL but was unable to substitute the procedure calls made by the legacy SQL, hence was exploring options on that. (I did not post the actual Tables names or package names , hence replaced it with dummy or generic names in my post.)
Seetharaman Venkat

Joined: Nov 07, 2010
Posts: 16
Any thoughts or Ideas on this?
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Use @Transient (or transient) to mark non-persisted fields.

You could map to a view instead of a table that call the stored procedure. Or mark it @Transient and set it in your app, or get method.

JPA requires relationship to be by Id, but some JPA providers support more complex relationships. In EclipseLink you can define a relationship using an Expression, or custom SQL or a StoredProcedureCall.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Seetharaman Venkat

Joined: Nov 07, 2010
Posts: 16
Thanks you for the suggestion, James.

Now I am faced with another issue;
I am planning to utilize ehCache for secondary level caching,
and since I am using Hibernate+JPA and there will be entity classes with Transient variables, is there any way i could save thae transient variable information in the secondary level cache?

Please let me know.

Seetharaman Venkat

Joined: Nov 07, 2010
Posts: 16
Any Ideas, suggestions?
I agree. Here's the link:
subject: Question on JPA
It's not a secret anymore!