• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How to create Inverse property reference using annotations

 
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,

 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!