Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] @ManyToMany Join table not being picked up

Hi,
 
Two tables ye_fund_manager and ye_fm_contacts have a many to many
relationship. The join table between them is called ye_fm_to_contacts,
this is on oracle 10G.
 
@Entity
@Table(name="YE_FUND_MANAGER")
public class YeFundManager

@ManyToMany
@JoinTable(name="YE_FM_TO_CONTACT", joinColumns =
@JoinColumn(name="FM_ID_NUM"),
inverseJoinColumns =@JoinColumn(name="CONTACT_ID_NUM"))
private Collection<YeFmContacts> contactsList;


@Entity
@Table(name="YE_FM_CONTACTS")
public class YeFmContacts

private Collection<YeFundManager> fundManagers;
	
@ManyToMany(mappedBy="contactsList")
public Collection<YeFundManager> getFundManagers() { 
	return fundManagers;
}


My test code to check that this works is:

em.getTransaction().begin();

Query q = em.createQuery("select m from YeFundManager m");
List<YeFundManager> list = q.getResultList();

for (YeFundManager fm : list) {

     Collection<YeFmContacts> contacts = fm.getContactsList();
     for (YeFmContacts c : contacts) {
     System.out.println(fm.getFmDisplayName() + ":" +
c.getContactName());
      }
}
        
System.out.println("REVERSE VIEW");

q = em.createQuery("select m from YeFmContacts m");
List<YeFmContacts> listC = q.getResultList();
         
for (YeFmContacts c: listC){
    Collection<YeFundManager> fmlist = c.getFundManagers();
         for (YeFundManager fm : fmlist){
                 System.out.println(c.getContactName() + ":" +
fm.getFmDisplayName());//<<<<
     }
}

The query from the owning side looks good (i.e. up till REVERSE VIEW),
however the reverse is not. I'm getting the error at the point where I
reference "fm.getFmDisplayName());//<<<<". The error is:

Internal Exception: java.sql.SQLException: ORA-00942: table or view does
not exist

Error Code: 942
Call: SELECT t1.ID_NUM, t1.FM_DISPLAY_NAME, t1.FM_FUND_MANAGER,
t1.STATUS, t1.FUND_NAME, t1.DELIVERY_METHOD, t1.ADMIN_CONTACT_ID,
t1.TAX_CONTACT_ID, t1.ADDITIONAL_COMMENTS, t1.SOFT_DELETE,
t1.LAST_MODIFIED_DATE, t1.CREATED_DATE, t1.CREATED_BY,
t1.LAST_MODIFIED_BY FROM YE_FM_CONTACTS_YE_FUND_MANAGER t0,
YE_FUND_MANAGER t1 WHERE ((t0.YeFmContacts_ID_NUM = ?) AND (t1.ID_NUM =
t0.fundManagers_ID_NUM))
	bind => [60]

I can see its trying to find the default table
YE_FM_CONTACTS_YE_FUND_MANAGER, but this has been changed in the
YeFundManagers entity. I've tried setting it on the YeFmContacts entity
but it gives the same result.

The setup I have here is specified in the eclipselink online docs so not
sure what's up here?

Regards,

Matt


NOTICE
This e-mail and any attachments are confidential and may contain copyright material of Macquarie Group Limited or third parties. If you are not the intended recipient of this email you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. Macquarie Group Limited does not guarantee the integrity of any emails or any attached files. The views or opinions expressed are the author's own and may not reflect the views or opinions of Macquarie Group Limited.



Back to the top