This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on JPA

 
Seetharaman Venkat
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this an interview question? Or an assignment?
 
Seetharaman Venkat
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any thoughts or Ideas on this?
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkat
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any Ideas, suggestions?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic