Object in multiple tables
Hi guys, How do I break an object into multiple tables with iBatis. For example, suppose the following object: Message: dtMsg, Msg, annex, annex. How would you write the fields: dtMsg and message, in message table and the fields: annex, in other table. How can I map this situation. The second table must have a foreign key to the first table(message). This is an simple example. I have a complex object that should to be mapped in multiple tables. How do this mapping? Can anyone give me an example please. Thank you. -- View this message in context: http://www.nabble.com/Object-in-multiple-tables-tp25741806p25741806.html Sent from the iBATIS - User - Cs mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org
Re: Object in multiple tables
All depends on how you are going to be getting your primary key and how you would like it hydrated into your child tables. There are 2 ways to handle this, the first is to handle the inserts through a parent transaction and then do the subsequent insert calls through seperate mapper.Insert(...) You can get your auto-incremented primary key back using the selectKey element and push it back into your object. OR, It is possible to group multiple insert statements into one insert element, but its not very elegant or nice to your maint. developers :) On Sun, Oct 4, 2009 at 1:20 PM, jmsandy jmsa...@gmail.com wrote: Hi guys, How do I break an object into multiple tables with iBatis. For example, suppose the following object: Message: dtMsg, Msg, annex, annex. How would you write the fields: dtMsg and message, in message table and the fields: annex, in other table. How can I map this situation. The second table must have a foreign key to the first table(message). This is an simple example. I have a complex object that should to be mapped in multiple tables. How do this mapping? Can anyone give me an example please. Thank you. -- View this message in context: http://www.nabble.com/Object-in-multiple-tables-tp25741806p25741806.html Sent from the iBATIS - User - Cs mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org -- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/
Re: Object in multiple tables
Thanks Michael. Indeed the first option and much more interesting. Thanks for the tip. Michael McCurrey-3 wrote: All depends on how you are going to be getting your primary key and how you would like it hydrated into your child tables. There are 2 ways to handle this, the first is to handle the inserts through a parent transaction and then do the subsequent insert calls through seperate mapper.Insert(...) You can get your auto-incremented primary key back using the selectKey element and push it back into your object. OR, It is possible to group multiple insert statements into one insert element, but its not very elegant or nice to your maint. developers :) On Sun, Oct 4, 2009 at 1:20 PM, jmsandy jmsa...@gmail.com wrote: Hi guys, How do I break an object into multiple tables with iBatis. For example, suppose the following object: Message: dtMsg, Msg, annex, annex. How would you write the fields: dtMsg and message, in message table and the fields: annex, in other table. How can I map this situation. The second table must have a foreign key to the first table(message). This is an simple example. I have a complex object that should to be mapped in multiple tables. How do this mapping? Can anyone give me an example please. Thank you. -- View this message in context: http://www.nabble.com/Object-in-multiple-tables-tp25741806p25741806.html Sent from the iBATIS - User - Cs mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org -- Michael J. McCurrey Read with me at http://www.mccurrey.com http://chaoticmindramblings.blogspot.com/ -- View this message in context: http://www.nabble.com/Object-in-multiple-tables-tp25741806p25743218.html Sent from the iBATIS - User - Cs mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-cs-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-cs-h...@ibatis.apache.org