ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: iBatis enhancements (Annotations and/or Dynamic beanutils support)
Date Wed, 03 May 2006 02:30:23 GMT
You didn't say how you were getting "value" (I'm assuming you must parse the
text line and do type conversions somewhere else), but why not something as
simple as this...

HashMap hm = new HashMap();
hm.put(fieldName, value);
service.insert(hm);

Am I missing something that's really fundamental?

Jeff Butler


On 5/2/06, Brent Ryan <bryan@blackboard.com> wrote:
>
>  If I have a text file with fields name, email, phone and I want to load
> this into a table using iBatis... how would you do this?
>
> Example text file:
> brent, abc@something.com, 5555555555
>
> //This would normally be loaded from a properties file
> String fieldName = "name";
>
> DynaBean obj = new LazyDynaBean();
>
> PropertyUtils.set(obj, fieldName, value);
>
> //insert my data using iBatis
> service.insert(obj);
>
> Now, how can I do that with a hashmap?
>
> Brent
>
> *From:* Jeff Butler [mailto:jeffgbutler@gmail.com]
> *Sent:* Tuesday, May 02, 2006 7:10 PM
>
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: iBatis enhancements (Annotations and/or Dynamic beanutils
> support)
>
>  Is there some reason that a HashMap won't work for you here?  It works
> fine in iBATIS with exactly the syntax you've specified below.  You're
> probably doing the same amount of work to load up the DynaBean that you
> would do to load a HashMap.
>
> Regarding annotations - As I thought more about it I remembered that we've
> just recently stopped supporting JDK 1.3!  I think it will be a while
> before can sefely add any Java 5 specific features.
>
> Jeff Butler
>
>
> On 5/2/06, Brent Ryan <bryan@blackboard.com> wrote:
> >
> >  Well, my usecase for beanutils is that I didn't want to have to create
> > POJO's at all.  I wanted my application and iBatis to figure out dynamically
> > the data that I'm putting into a database.  In this particular application I
> > have a bunch of configuration information in a properties file and one of
> > the configurations is "fieldNames".  These field names correspond directly
> > to the fieldNames in my POJO's.
> >
> > If iBatis supported this then I would be able to specify something like
> > this in my sqlmap:
> >
> > <typeAlias alias="merchant" type="
> > org.apache.commons.beanutils.LazyDynaBean"/>
> >
> > <insert id="insertMerchant" parameterClass="merchant">
> >     <selectKey resultClass="int" keyProperty="merchantId" > select
> > EXTENDED_MERCHANT_SEQ.NEXTVAL as merchantId from DUAL</selectKey>
> >     insert into EXTENDED_MERCHANTS (MERCHANT_ID, NAME, CONTACT, EMAIL,
> > PHONE, COMMENTS, VENDOR_ID, VENDOR_SITE_ID, INVOICE_EMAIL,
> > EXTERNAL_MERCHANT)
> >     values (#merchantId#, #merchantName#, #merchantContact#,
> > #merchantEmail#, #merchantPhone#, #merchantComments#, #vendorId#,
> > #vendorSiteId#, #invoiceEmail#, #externalMerchant#)
> >   </insert>
> > Basically, I'm lazy and I didn't want to have to create a POJO.  It
> > seems like I'm constantly having to enter the same field names over and over
> > again...  This would just be one place to eliminate that.
> >
> > For annotations...  I wasn't really sure other then I've seen some cool
> > uses with the hibernate annotations.  Maybe replace some of the result map
> > configurations, default values, etc.. with annotations.  Other then that,
> > I'm not sure of another use for this...
> >
> > Brent
> >
> >  *From:* Jeff Butler [mailto:jeffgbutler@gmail.com ]
> > *Sent:* Tuesday, May 02, 2006 6:15 PM
> > *To:* user-java@ibatis.apache.org
> > *Subject:* Re: iBatis enhancements (Annotations and/or Dynamic beanutils
> > support)
> >
> >  Regarding beanutils - this has been discussed on the list several
> > times.  The general feeling is that we want to keep the iBATIS dependancies
> > to a minimum, so I don't think we'll see direct support of DynaBeans.  You
> > certainly could use a HashMap as a result class in iBATIS, and then create
> > LazyDynaMap instances from the returned HashMaps.  This would give you
> > DynaBean behavior and would work directly with iBATIS today.  Is there
> > something about that approach that doesn't work for you?
> >
> > Regarding annotations - could you be more specific about what you're
> > looking for?
> >
> > Jeff Butler
> >
> >
> > On 5/2/06, Brent Ryan <bryan@blackboard.com > wrote:
> > >
> > >  Anyone know if Java 5 annotations or dynamic beanutils support will
> > > work in a future version of iBatis?
> > >
> > > Brent
> > >
> > > **
> > >
> > > This e-mail is intended only for the personal and confidential use of
> > > the recipient(s) named above.
> > > It may include Blackboard confidential and proprietary information,
> > > and is not for redistribution.
> > >
> >
> > **
> >
> > This e-mail is intended only for the personal and confidential use of
> > the recipient(s) named above.
> > It may include Blackboard confidential and proprietary information, and
> > is not for redistribution.
> >
>
> **
>
> This e-mail is intended only for the personal and confidential use of the
> recipient(s) named above.
> It may include Blackboard confidential and proprietary information, and is
> not for redistribution.
>

Mime
View raw message