wood burning stoves 2.0*
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
Author

Question on JPA

Seetharaman Venkat
Greenhorn

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



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
->-->@OneToOne TEST_TABLE1 on TEST_TABLE1_ID->>@OneToOne TEST_TABLE3 on TEST_TABLE3_ID
->--->@OneToOne TEST_TABLE2 on TEST_TABLE2_ID->>@OneToOne TEST_TABLE4 on TEST_TABLE4_ID

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
Bartender

Joined: Apr 14, 2004
Posts: 10336

Is this an interview question? Or an assignment?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Seetharaman Venkat
Greenhorn

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
Greenhorn

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

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

2)
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.

3)
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
Greenhorn

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
Greenhorn

Joined: Nov 07, 2010
Posts: 16
Any Ideas, suggestions?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on JPA
 
Similar Threads
How toPersist Value in the Tables Using Entity Bean
non-standard join in ManyToOne
Could not determine type for: java.util.Set
JPA - need help with query
Servlet doesn't persist on db