File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to create Inverse property reference using annotations

 
Roger manning
Greenhorn
Posts: 6
  • 0
  • 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'?
 
Carles Gasques
Ranch Hand
Posts: 199
1
  • 0
  • 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,

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic