Ummm....no. There's no way to insert into multiple tables using a single statement, unless you have DBMS that supports it. The only way I've seen this implemented in RDBMS is with a view that has insert rules applied to it (already very simple designs, that don't benefit much from the additional simplification).
Hibernate can't insert into multiple tables with a single statement any more than it can solve world hunger or peace on earth. Clinton On 4/22/05, Leonardo Holanda <[EMAIL PROTECTED]> wrote: > Yes! Using hibernate :D > > -----Mensagem original----- > De: Sasha Borodin [mailto:[EMAIL PROTECTED] > Enviada em: sexta-feira, 22 de abril de 2005 16:43 > Para: ibatis-user-java@incubator.apache.org > Assunto: Re: Mapping of one object to several tables? > > Can you even do an INSERT that involves multiple tables? > > -Sasha > > > From: Brandon Goodin <[EMAIL PROTECTED]> > > Reply-To: <ibatis-user-java@incubator.apache.org> > > Date: Fri, 22 Apr 2005 13:39:30 -0600 > > To: <ibatis-user-java@incubator.apache.org> > > Subject: Re: Mapping of one object to several tables? > > > > If you are trying to prevent duplicate inserts you would need to > > perform a select on the database to make sure it doesn't exist first. > > > > Brandon > > > > On 4/22/05, toto titi <[EMAIL PROTECTED]> wrote: > >> Hello, > >> > >> I am new to iBatis/SQL and don't really know if the following is > >> possible or not.. Also, I am not sure where to ask this question as I > > >> don't know if it relates more to iBatis or SQL... so please bear with > >> me. > >> > >> Let's say I want to save the following object: > >> class person { > >> String name; > >> String country; > >> } > >> > >> In order to save space in my db I will save the > >> country in a table of its own and refer to each record > >> from the name table by an id: > >> > >> personTable > >> ----------- > >> id > >> name > >> countryId > >> > >> countryTable > >> ------------ > >> id > >> country > >> > >> Now, I know that for a select statement I can just do > >> a join to get my object back: > >> SELECT name, country from personTable, countryTable > >> where countryId=countryTable.id; > >> > >> My question is, how do I insert a new person in these > >> two tables with only one query? Taking into account > >> that the country for the new person object might > >> already have been inserted.. > >> > >> Thanks for any help! > >> > >> __________________________________________________ > >> Do You Yahoo!? > >> Tired of spam? Yahoo! Mail has the best spam protection around > >> http://mail.yahoo.com > >> > >