Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Nested select and merge in OpenJPA

 
tech karthik
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to achieve the following operation using openJPA. I have two entities. USER and CITIES. I have a table USER with columns USER_NAME and CITY_DESC. I also have a table CITIES which contains columns PIN_CODE and CITY_DESC.

On the UI I get only PIN_CODE data from user. I need to save USER table making a join with CITIES table. I want CITY_DESC populated when I save USER entity using EntityManager.merge() method.

Something like this:


OpenJPA version : 2.2.2

Kindly help.
 
Dave Tolls
Ranch Hand
Posts: 2099
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming PIN_CODE is the primary key for the CITIES table, why not simply store the PIN_CODE in the USER table, and make that a foreign key to the CITIES table?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic