How can this be? To have a many-to-many relationship the join table must already exist - it is not something that gets created dynamically by Hibernate or any other OR system.
The join table's existence is what creates the ability for one instance of class A to be related to multiple instances of class B, and the inverse where one instance of class B is related to multiple instances of class A. Your tables would look something like A ----------- | id | name | ----------- B ----------- | id | name | ----------- AB ------------------ | id | a_id | b_id | ------------------ It does not have to look precisely like the above, but the join table must exist and have references to both class A and B - through either an object id key or a natural key. Hope this helps - Richard > From: cfoy <[EMAIL PROTECTED]> > Reply-To: <users@appfuse.dev.java.net> > Date: Tue, 20 May 2008 06:05:57 -0700 (PDT) > To: <users@appfuse.dev.java.net> > Subject: Re: [appfuse-user] Hibernate hql join on tables with no relationship > > > Hi Mike, > > Thanks for the reply. The relationship between the two tables is a many to > many. In order to do a many to many relationship in JPA you normally need a > Join Table. We have only select permissions on the database and cannot > create this join table. > > Do you still reckon it is possible? > > Thanks in advance > > Abu > > Mike Horwitz wrote: >> >> Yes - as far as I know Hibernate does not rely on constraints being >> present >> in the underlying database. You will need to make sure your data is valid >> though. >> >> Mike >> >> 2008/5/20 cfoy <[EMAIL PROTECTED]>: >> >>> >>> I need to run some read only reports by joining the following two tables: >>> >>> 1) payments >>> 2) subscriptions >>> >>> The join will be on a column in both called paymentreference. >>> I do not have control over the underlying database and the two tables and >>> the two tables do not have a relationship i.e. no foreign keys exist. >>> >>> Is it possible to add the relationship primary and foreign key in the >>> annotations for the pojos and then use hql to perform the join even >>> though >>> there are no keys in the database? At the moment we are using a native >>> sql >>> query and using a results transformer to map the results to a pojo. >>> >>> I am using hibernate 3.2 annotations. >>> >>> Thanks in advance >>> >>> Abu >>> -- >>> View this message in context: >>> http://www.nabble.com/Hibernate-hql-join-on-tables-with-no-relationship-tp17 >>> 338465s2369p17338465.html >>> Sent from the AppFuse - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> > > -- > View this message in context: > http://www.nabble.com/Hibernate-hql-join-on-tables-with-no-relationship-tp1733 > 8465s2369p17339849.html > Sent from the AppFuse - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]