• 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to create Inverse property reference using annotations  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've looked around and can't seem to find a solution to my issue so please read on to see what it is. Any help much appreciated.

* I've got table A which contains an 'Id' column (but table A has no reference to any column in table B)
* I have table B which contains a column called 'table_A_ID' which maps to the 'Id' column of table A.
* There is a 1 to 1 mapping between rows in table A and table B.

My java entities currently look like this :-

and B is defined as :-

My question concerns how I get instances of B onto instances of A (since there's no reference to B on A in the DB)? I think I need to use joins but don't know what annotations I need to use to do this kind of 'reverse lookup'?
 
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try @OneToOne (mappedBy="owner") indicating who is the owner of the relation ship.

jpa reference @OneToOne


Cheers,

 
Good night. Drive safely. Here's a tiny ad for the road:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!