• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Nested select and merge in OpenJPA

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.
Master Rancher
Posts: 4668
  • 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?
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic