Generally speaking, ObjectFactory is reponsible for instantiating classes (including providing constructor parameters). The MetaClass/MetaObject library, including the ObjectWrapper abstraction are reponsible for manipulating / mutating existing objects.
Both ObjectWrapper and ObjectFactory can be overridden. Can you use a combination of the two to do what you need? There are examples of both in the iBATIS source. Also, you should be able to find the scala example/plug-in if you search the mailing list archives. I'll post it here when I'm at a computer, if you haven't already found it. Cheers, Clinton On 2010-02-24, Alexei Sokolov <alexei.soko...@gmail.com> wrote: > Clinton, > > Sorry, I did not mean to criticize the framework. I'm just wondering if I > understand how you do things, and if the code can be improved upon. > > What I see so far is that I cannot separate object construction mechanism > from the client view of the object. Think StringBuilder/String in java, > ListBuffer/List in scala, and other similar classes. I want users of my > classes to see String, List, etc., but I want ibatis to use StringBuilder > (stringbuilder is not the real usecase, but just to show my point) and > ListBuffer to construct them. It could be due to how I want users to see the > data, or it could be due to the fact that I can construct the object more > efficiently this way, or I want it to be immutable. > > If you'll say that such pattern is outside of ibatis scope, it is OK. > However, I think this refactoring may benefit others, including scala > users. > > Alex > > On Wed, Feb 24, 2010 at 8:44 PM, Clinton Begin > <clinton.be...@gmail.com>wrote: > >> LOL... sorry I thought that was funny. :-) >> >> But really, you're really polarizing this discussion with broad criticisms >> of how our software is designed. It's hard to comment on your needs or to >> help you. >> >> I'm not exactly sure what you're trying to do, but you're digging pretty >> deep into the guts of the system, parts that weren't really intended for >> other people to extend or change (or at the very least at your own risk). >> >> So it seems to me that if you have to dig that deep into the core of the >> library, it's probably the wrong fit and you'll have an uphill battle and >> a >> poor experience overall. >> >> So rather than criticize our framework because it doesn't do what you need >> it to, it might be best if you look for a better fit. There are others. >> Hibernate is one, and yes it's well designed. >> >> As for a friendly community, I can assure you that if you broadly >> criticize >> them because their square peg doesn't fit into the round hole, you'll >> probably meet with a similar reaction. >> >> Cheers, >> Clinton >> >> >> On Wed, Feb 24, 2010 at 9:03 PM, Alexei Sokolov >> <alexei.soko...@gmail.com>wrote: >> >>> Not sure what are you trying to say. >>> >>> That hibernate has friendly community? Or that they have a better >>> designed >>> library? >>> >>> >>> -- Alex >>> Sent from my mobile >>> >>> On Feb 24, 2010, at 7:28 PM, Clinton Begin <clinton.be...@gmail.com> >>> wrote: >>> >>> Yes, iBATIS has a mechanism that allows you to do what you want to do. >>> It's called Hibernate. >>> >>> <https://www.hibernate.org/>https://www.hibernate.org/ >>> >>> Enjoy. >>> >>> On Wed, Feb 24, 2010 at 8:11 PM, Alexei Sokolov >>> <<alexei.soko...@gmail.com> >>> alexei.soko...@gmail.com> wrote: >>> >>>> Well, Microsoft Office has Excel, which is a good spreadsheet. Does >>>> ibatis has a mechanism that allows me to do what I want to do? >>>> >>>> If intented use for objectwrapper was scala, why didn't you call it >>>> scalaobjectwrapper? Obviously you had other potential uses in mind. >>>> >>>> BTW, can you point me to some scala examples? Can ibatis map java lists >>>> and maps to scala lists and maps? >>>> >>>> Thanks, >>>> -- Alex >>>> Sent from my mobile >>>> >>>> On Feb 24, 2010, at 6:35 PM, Clinton Begin < <clinton.be...@gmail.com> >>>> clinton.be...@gmail.com> wrote: >>>> >>>> What you're trying to do with ObjectWrapper is beyond its intended use. >>>> It was never a consideration nor an intention for the ObjectWrapper to >>>> instantiate objects. ObjectWrapper was originally implemented to >>>> support >>>> Scala types, and perhaps to support a custom property naming convention >>>> or >>>> some other type (e.g. XML). >>>> >>>> It was not intended to change or intercept the result object lifecycle >>>> or >>>> override the result object entirely. >>>> >>>> You can call it a design problem if you like. But it's kind of like >>>> saying Microsoft Word has a design problem because it isn't a very good >>>> spreadsheet. >>>> >>>> Clinton >>>> >>>> On Wed, Feb 24, 2010 at 11:11 AM, Alexei Sokolov >>>> <<alexei.soko...@gmail.com><alexei.soko...@gmail.com> >>>> alexei.soko...@gmail.com> wrote: >>>> >>>>> Hello everyone, >>>>> >>>>> I'm new here, but either I don't understand ibatis internals or you >>>>> have >>>>> a design problem. First, let me share my understanding of how ibatis >>>>> handles >>>>> mapping of result sets to beans: >>>>> >>>>> In *ResultSetHandler.getRowValue() method you create object instance >>>>> using objectfactory. then you create metaobject for it, which in turn >>>>> creates objectwrapper for that object instance. Then you use meta >>>>> object >>>>> methods to populate property values on that object instance. During >>>>> this >>>>> process both metaobject and objectwrapper essentially write values >>>>> directly >>>>> to the object instance returned from object factory. >>>>> >>>>> Now, consider this scenario: let's say my object wrapper constructs >>>>> intermediate object first and populates its values. Than when I'm done >>>>> processing a row, I want to create actual object instance that will be >>>>> returned to the client. How do I do this with the current >>>>> implementation? >>>>> Ideally, it will be nice if ObjectWrapper had a method, say >>>>> 'getPopulatedInstance()' and then line 179 in >>>>> FastResultSetHandler.getRowValue() (and other such places) could be >>>>> rewritten like >>>>> >>>>> resultObject = foundValues ? >>>>> metaObject.getObjectWrapper().getPopulatedInstance() : null; >>>>> >>>>> instead of >>>>> >>>>> resultObject = foundValues ? resultObject : null; >>>>> >>>>> In other words, it would be nice if objectwrapper is able to create new >>>>> instances in addition to being able to work as decorator. >>>>> >>>>> Does it make sense at all? >>>>> >>>>> Thanks, >>>>> Alex >>>>> >>>>> >>>> >>> >> > -- Sent from my mobile device --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ibatis.apache.org For additional commands, e-mail: dev-h...@ibatis.apache.org