You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Josh Kamau <jo...@gmail.com> on 2010/04/26 15:42:21 UTC

Domain modeling

Hi team;

I am working on the domain model for  a project. I have a class named user
that has a class named UserType as one of the properties. I know when i want
to select all users, i will use joins to pick up all corresponding
usertypes. How do i do inserts? Do i have to write a handler for userType?
or can i do something like

   INSERT INTO users(... usertype_id ...) VALUES(...
#{usertype.usertype_id}...)

Please help;

I have spent the whole day trying to figure this out. Am using ibatis 3.0
and am new to ibatis.

Regards
Josh

Re: Domain modeling

Posted by Josh Kamau <jo...@gmail.com>.
Thanks for the reply.

How about cases where the type is not an enum. In my example, lets say the
UserType is not an enum but a Bean

On Mon, Apr 26, 2010 at 8:19 PM, Guy Rouillier <gu...@burntmail.com>wrote:

> We addressed this issue by creating enums for the type columns, then
> creating a type handler to map from the column value to the enum and vice
> versa.  In addition to the programming benefits of working with enums, you
> also let iBATIS handle the translations for both select and insert.
>
>
> On 4/26/2010 9:42 AM, Josh Kamau wrote:
>
>> Hi team;
>>
>> I am working on the domain model for  a project. I have a class named
>> user that has a class named UserType as one of the properties. I know
>> when i want to select all users, i will use joins to pick up all
>> corresponding usertypes. How do i do inserts? Do i have to write a
>> handler for userType? or can i do something like
>>
>>    INSERT INTO users(... usertype_id ...) VALUES(..
>> #{usertype.usertype_id}...)
>>
>> Please help;
>>
>> I have spent the whole day trying to figure this out. Am using ibatis
>> 3.0 and am new to ibatis.
>>
>> Regards
>> Josh
>>
>
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Re: Domain modeling

Posted by Guy Rouillier <gu...@burntmail.com>.
We addressed this issue by creating enums for the type columns, then 
creating a type handler to map from the column value to the enum and 
vice versa.  In addition to the programming benefits of working with 
enums, you also let iBATIS handle the translations for both select and 
insert.

On 4/26/2010 9:42 AM, Josh Kamau wrote:
> Hi team;
>
> I am working on the domain model for  a project. I have a class named
> user that has a class named UserType as one of the properties. I know
> when i want to select all users, i will use joins to pick up all
> corresponding usertypes. How do i do inserts? Do i have to write a
> handler for userType? or can i do something like
>
>     INSERT INTO users(... usertype_id ...) VALUES(..
> #{usertype.usertype_id}...)
>
> Please help;
>
> I have spent the whole day trying to figure this out. Am using ibatis
> 3.0 and am new to ibatis.
>
> Regards
> Josh


-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org