ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akins, Greg" <gak...@amervideo.com>
Subject RE: Mapping of one object to several tables?
Date Fri, 22 Apr 2005 19:48:53 GMT
I think that depends on what the OP was asking.

In Hibernate you can because it cascades the object insert into mutiple
database inserts.  

However, in some databases I believe you can do an insert to a view, as
long as the underlying joins are "simple" enough.



-----Original Message-----
From: Sasha Borodin [mailto:sasha@whoissasha.com] 
Sent: Friday, April 22, 2005 3:43 PM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Mapping of one object to several tables?


Can you even do an INSERT that involves multiple tables?

-Sasha


> From: Brandon Goodin <brandon.goodin@gmail.com>
> 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 <altrent2003@yahoo.com> 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
>> 



Mime
View raw message