Really, we might be able to make it work if we defined the relationships in the parameter map.
It's just not been done yet. If you want to take a crack at it, get the code from SVN and do it. Please note: I am not saying "Do it your damn self!" here, just encouraging you to try it if you have been thinking on it, and think you might want to. :-) We are also kicking around some ideas for iBATIS 3 - if you can find a generalized solution to this problem, maybe it can be a new feature we can wrap into it, too. Larry On Feb 20, 2008 9:38 AM, Alexey Kalmykov <[EMAIL PROTECTED]> wrote: > > Thanks, that is what I would like to know. I'm just curious why <select> > is able to handle object graphs, but insert/update - no? > > Best regards, Alexey Kalmykov > OpenWay > > > -----Original Message----- > From: Larry Meadors [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 20, 2008 7:35 PM > To: [email protected] > Subject: Re: insert/update objects graph > > > If I understand your question correctly, you want to take (for > example) an Order object with a list of OrderLine objects and insert > them by just saying this: > > sqlMap.insert("order.insert", myOrder); > > If so, then no, this is not a part of iBATIS. > > While that is a common ORM feature, iBATIS is not an ORM, it is a SQL > mapper - it maps objects to/from SQL, not objects to/from database > tables. > > That said, doing what you are asking is still pretty simple - here's a > (non-transactional) example: > > public insertOrder(Order order){ > // this assumes that the "order.insert" includes a selectKey element > sqlMap.insert("order.insert", order); > for(OrderLine ol:order.getOrderLines()){ > ol.setOrderId(order.getOrderId()); > sqlMap.insert("orderline.insert", ol); > } > } > > If you are using Spring, you add a transaction annotation, and > ba-da-bing. Done. > > For 4 lines of code, you have this instead: > > myOrderDao.insertOrder(myOrder); > > Larry > > > On Feb 20, 2008 9:01 AM, Alexey Kalmykov <[EMAIL PROTECTED]> > wrote: > > I am trying to evaluate iBATIS as an ORM solution for my project. I > really > > like the overall idea behind iBATIS and its approach to ORM. I have a > > question about insert and update operations. I've been successfully > loading > > graph of objects using resultMaps. But as far as I understand, I am > unable > > to insert/update a graph of user-defined objects *using only* iBATIS > > mapping. Am I right? If yes, was it an original intention not to > implement > > such feature or just there are some difficulties in iBATIS design that > > prevents from doing it? > > > > > > > > Actually, I hope that I am wrong and somehow I can insert/update a > graph of > > objects only using iBATIS mapping :) > > > > Thank you in advance. > > > > >
