ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Mapping of one object to several tables?
Date Fri, 22 Apr 2005 19:39:30 GMT
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