This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes OneToMany mappedBy composite (foreign) key gives empty collection - OpenJPA + EJB3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OneToMany mappedBy composite (foreign) key gives empty collection - OpenJPA + EJB3" Watch "OneToMany mappedBy composite (foreign) key gives empty collection - OpenJPA + EJB3" New topic
Author

OneToMany mappedBy composite (foreign) key gives empty collection - OpenJPA + EJB3

Fera Tsie
Greenhorn

Joined: Oct 31, 2012
Posts: 1
Hi,

I currently have 3 tables with the following structure:

company
----------
co_id [pk]
co_name

companyaddress
-------------------
co_id [pk] [fk: references company.co_id]
addr_type [pk]
addr_street
addr_suburb
addr_state
addr_postcode

companyemergencynumber
--------------------------------
emerg_id [pk]
co_id [fk: references companyaddress.co_id AND company.co_id]
addr_type [fk: references companyaddress.type_id]
emerg_phone


and the quantitative relationship between them are as follows:
company (1 to many) companyaddress (1 to many) companyemergencynumber
>> in other words:
* each company can have 1 or more companyaddress
* each companyaddress can have 1 or more companyemergencynumber

I would like to list all addresses and their corresponding emergency numbers for a selected company, and I've implemented my entity classes as follow:




My problem is when trying to access emergency numbers linked to company address. Emergency numbers do not seem to get retrieved even though OneToMany relational mapping has been defined and fetchType has been set to FetchType.EAGER.


Could anyone please help? Where did I go wrong

many thanks
Fera



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OneToMany mappedBy composite (foreign) key gives empty collection - OpenJPA + EJB3