• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on JPA

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this an interview question? Or an assignment?
 
Seetharaman Venkat
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts or Ideas on this?
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any Ideas, suggestions?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic