This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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
 
Similar Threads
using 2 @OnetoMany annoations in one Entity Class
JPA - EntityExistsException with Composite Id
IllegalArgumentException: cannot remove/save a detached entity
Edit primary key, if it's a foreign key
Could not determine type for: java.util.Set