Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Fera Tsie
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic