aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to create Inverse property reference using annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to create Inverse property reference using annotations" Watch "How to create Inverse property reference using annotations" New topic
Author

How to create Inverse property reference using annotations

Roger manning
Greenhorn

Joined: May 02, 2011
Posts: 6
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

Joined: Apr 19, 2013
Posts: 199
    
    1
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
 
subject: How to create Inverse property reference using annotations