No, in an OO world it must exist... But in a DB that you don't control, 2 tables both with "paymentreference" can be considered a many 2 many of each other.
I would imagine H8 could still handle this. Have you tried the H8 forum? Could you possibly go through the PaymentReference table (whatever that is) and do a unidirectional many2one and then one2many joins? E.g. Payments many2one PaymentReference PaymentReference one2many Subscriptions and vice versa Not most performant of course... Tim On Tue, May 20, 2008 at 6:12 PM, Richard Mixon <[EMAIL PROTECTED]> wrote: > 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] > >