Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 70941 invoked from network); 18 Feb 2010 15:58:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Feb 2010 15:58:54 -0000 Received: (qmail 35842 invoked by uid 500); 18 Feb 2010 15:58:54 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 35796 invoked by uid 500); 18 Feb 2010 15:58:53 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 35788 invoked by uid 99); 18 Feb 2010 15:58:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2010 15:58:53 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of clinton.begin@gmail.com designates 209.85.221.190 as permitted sender) Received: from [209.85.221.190] (HELO mail-qy0-f190.google.com) (209.85.221.190) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2010 15:58:45 +0000 Received: by qyk28 with SMTP id 28so5357676qyk.25 for ; Thu, 18 Feb 2010 07:58:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=1MNo1JYlxMHa3zZ59IZ5T/4oLFpR7ZtDwBZ09mLYdk4=; b=aA5UKwAowYTC8YnjMVA90uh8Bl1eaGUvvG/Q0y1rto5q5bSkX3QZedzt7FJHaRJWkL 3Ht3Jos2J868FDERTEMxIOANO27QvWWK0y7X9dQxY0qXWIzmElx5RVuEgFOi0ufCJd1t ur1z/wE3GvGMN377nqrn3Ft8M6suVCN4G92ek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=fywTGNOn+amZ0kFhbF0RG5+ompqxrHLy/TD733XckbKX0qj5IX2kRpoVQ2K7WrxKip FQjC+kf8na1VLUgfDHamE1ll+Xo8u4JvhMXKl+8qTJmTw7JJDSAliHV5kBe9EJGR0uz3 MAbpH2Qscxo0j+csAKZMV3FAgqQjM0kFekrEQ= MIME-Version: 1.0 Received: by 10.224.23.141 with SMTP id r13mr2573777qab.334.1266508704159; Thu, 18 Feb 2010 07:58:24 -0800 (PST) In-Reply-To: <8017c6041002180308i119bb6f1mfd2dbb6c46ec425d@mail.gmail.com> References: <8017c6041002180308i119bb6f1mfd2dbb6c46ec425d@mail.gmail.com> From: Clinton Begin Date: Thu, 18 Feb 2010 08:58:04 -0700 Message-ID: <16178eb11002180758w14f0899erf328a7ffb56dbc58@mail.gmail.com> Subject: Re: iBatis annotation related questions To: user-java@ibatis.apache.org Content-Type: multipart/alternative; boundary=00148534b5b06a97ef047fe20917 --00148534b5b06a97ef047fe20917 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable Hi Jan, >> expectations come from iBatis 3 Whitepaper Just to be clear, it wasn't a "white paper" it was a community whiteboard for brainstorming ideas. So it contained goals and ideas, but there was never a commitment to any of them. >> Multilevel Configuration Ultimately I decided not to implement it this way because it became hard to trace where behavior was configured. To fully understand how a statement might behave or perform, you would have had to look in 3 places. I wasn't satisfied with that, so I made it to be either XML or Annotations per statement. You can happily mix mappers with annotations or xml statements, but each statement must use either one or the other. >> to state all properties in order to alter the single one That's configurable. See the docs under the automappingBehavior setting (I think that's what it's called). >>annotations You think it's unpleasant? You should have seen me the day that I had to remove WORKING CODE from my system because Sun changed the behavior of Java Annotations between Java 1.5 and 1.6. In a nutshell, circular references are not supported in the Annotations framework. All of your best hopes and dreams of having something better ar= e dashed by this one limitation. There was a workaround in Java 1.5, but Sun considered it a compiler bug, so they "fixed" the workaround in JDK 1.6. I= f you want to see it, you can dig back through a few hundred commits and see where I removed that behavior. A shame. If this was C# I would have been able to fully realize the vision of where we wanted to take the annotation (or attributes in C#) approach. **>> 3 combinations of annotations and xml In general, I recommend using annotations for simple things, and use XML fo= r anything more complicated. Sorry, but Java annotations are just too messy, limited and ugly. There's a million reasons why we had to scale back the behavior and limit it to what you see now. If you want to understand why, = I encourage you to try to implement some of your suggestions. You'll find th= e same challenges. >> 4 automatic (generated) SQL Yes, I completely ditched the idea of generating SQL. It's just a road tha= t I wasn't prepared to take iBATIS down. >> 5 dynamic sql in annotations Yes, SelectProvider and the SQL Builder framework are the only way (other than writing your own). I wasn't about to start putting XML embedded in SQ= L embedded in strings embedded in annotations... that's out of hand and bad practice IMHO. I appreciate your questions, but please realize that everything was considered. Some things were left out for very good design reasons, others because of limitations in Java and others we might just not have had a chance to implement yet. Clinton 2010/2/18 Ing. Jan Novotn=FD > Hello, > > I am going to have a presentation about iBatis 3 at Czech JUG. I have = a > 3-year experience with iBatis-2 and now I am doing little research on wha= t's > new in upcoming iBatis 3 release. Most of my expectations come from iBati= s 3 > Whitepaper at the iBatis Confluence site. Now I am testing the new versio= n > and there are some things I didn't expect. I will be very pleased if anyo= ne > capable could answer me following questions so that I may forward them to > the attendees of CZ JUG: > > * 1) multilevel configuration* > Firstly I thought that there would be a chance to override less > prioritized level of configuration. Meaning, that if I have SQL represent= ed > in an @Select annotation and I create XML statement in mapper file with t= he > same name, this XML declaration will take over the annotation and will be > used instead. Reality is that iBatis will fail to start complaining about > duplicate declaration. As I discovered, I can use only one or the other w= ay > - I can combine XML file with annotation based Java DAO, but they must no= t > overlap in the sense of statement declaration. Is that right? Why is that > done this way? > Next I thought there could be some means to explicitly say, that so= me > parts of the lower configuration level fit for me and therefore ease my l= ife > a little. Let say I have ResultMap statement in XML configuration and 95%= of > its properties is fine by convention, but I need only to specify more sin= gle > property or declare association / collection mapping. In that case I have= to > state all properties in order to alter the single one that is needed to b= e > extra taken care of (or at least these are my findings from the tests I > wrote). What I really want to say is: use convention to all properties > except those that I explicitly configure in XML - that is not possible, i= s > it? > > * 2) annotations* > Another unpleasant surprise was, that I am not able to get along wi= th > annotations to specify mapping - annotation @Collection is > missing. Also @Association is not present - but as I discovered, it's > possible to write @Result annotations in the way that associated object g= ets > mapped. In documentation I found a statement, that annotations in Java > aren't powerfull enough to make some things possible, but I can't make up > why @Collection annotation is not possible to be made. > > * 3) combination of XML and annotations* > I tried combination of XML and annotations (due to lack of > @Collection annotation) to specify @Select annotation but specify output = as > a ResultMap mapping in the XML configuration. But that's not possible too= . > Mixing configuration from annotations and XML is not possible in any way = I > guess. Ok, but is there any way how to reuse my annotations, to get the s= ame > behaviour as reusing ResultMap mapping in different statements of XML > configuration?! > > * 4) automatic SQL implementation* > I didn't find any piece of this functionality. May I take it, that > this was completely discarded? > > * 5) annotations and dynamic SQL* > Finally I didn't find any clue how to use dynamic SQL in annotation= s. > Does that mean that @SelectProviders are the only way how to make dynamic > queries by the Java code? > > Thanks for your time and answers I can use in my presentation if anyon= e > asks. Please, don't be offended by my questions, generally I think iBatis= is > a great DAO framework. > > Cheers Jan > > -- > -------------------------------------------------------------- > Ing. Jan Novotn=FD > @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ > http://blog.novoj.net > My=B9lenky dne otce Fura > -------------------------------------------------------------- > --00148534b5b06a97ef047fe20917 Content-Type: text/html; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable Hi Jan,

>> expectations come from iBatis 3 Whitepaper

= Just to be clear, it wasn't a "white paper" it was a communit= y whiteboard for brainstorming ideas. So it contained goals and ideas, but = there was never a commitment to any of them.=A0


>> Multilevel Configuration

Ultimately I decided not t= o implement it this way because it became hard to trace where behavior was = configured.=A0 To fully understand how a statement might behave or perform,= you would have had to look in 3 places.=A0 I wasn't satisfied with tha= t, so I made it to be either XML or Annotations per statement.=A0 You can h= appily mix mappers with annotations or xml statements, but each statement m= ust use either one or the other.

>> to state all properties in order to alter the single one
<= br>That's configurable.=A0 See the docs under the automappingBehavior s= etting (I think that's what it's called).

>>annotation= s

You think it's unpleasant?=A0 You should have seen me the day that = I had to remove WORKING CODE from my system because Sun changed the behavio= r of Java Annotations between Java 1.5 and 1.6.

In a nutshell, circu= lar references are not supported in the Annotations framework.=A0 All of yo= ur best hopes and dreams of having something better are dashed by this one = limitation.=A0 There was a workaround in Java 1.5, but Sun considered it a = compiler bug, so they "fixed" the workaround in JDK 1.6.=A0 If yo= u want to see it, you can dig back through a few hundred commits and see wh= ere I removed that behavior.=A0

A shame.=A0 If this was C# I would have been able to fully realize the = vision of where we wanted to take the annotation (or attributes in C#) appr= oach.

>> 3 combinations of annotations and xml

In general, I recommend using annotations for simple things, and use XML fo= r anything more complicated.=A0 Sorry, but Java annotations are just too me= ssy, limited and ugly.=A0 There's a million reasons why we had to scale= back the behavior and limit it to what you see now.=A0 If you want to unde= rstand why, I encourage you to try to implement some of your suggestions.= =A0 You'll find the same challenges.

>> 4 automatic (generated) SQL

Yes, I completely ditched t= he idea of generating SQL.=A0 It's just a road that I wasn't prepar= ed to take iBATIS down.

>> 5 dynamic sql in annotations

Yes, SelectProvider and the SQL Builder framework are the only way (other t= han writing your own).=A0 I wasn't about to start putting XML embedded = in SQL embedded in strings embedded in annotations... that's out of han= d and bad practice IMHO.

I appreciate your questions, but please realize that everything was con= sidered.=A0 Some things were left out for very good design reasons, others = because of limitations in Java and others we might just not have had a chan= ce to implement yet.

Clinton

2010/2/18 Ing. Jan Novotn=FD = <novotnaci@gmai= l.com>
Hello,

=A0=A0 I am going to have a presentation about iBatis 3 at Cz= ech JUG. I have a 3-year experience with iBatis-2 and now I am doing little= research on what's new in upcoming iBatis 3 release. Most of my expect= ations come from iBatis 3 Whitepaper at the iBatis Confluence site. Now I a= m testing the new version and there are some things I didn't expect. I = will be very pleased if anyone capable could answer me following questions = so that I may forward them to the attendees of CZ JUG:

=A0 1) multilevel configuration
=A0=A0=A0=A0=A0 Firstly I tho= ught that there would be a chance to override less prioritized level of con= figuration. Meaning, that if I have SQL represented in an @Select annotatio= n and I create XML statement in mapper file with the same name, this XML de= claration will take over the annotation and will be used instead. Reality i= s that iBatis will fail to start complaining about duplicate declaration. A= s I discovered, I can use only one or the other way - I can combine XML fil= e with annotation based Java DAO, but they must not overlap in the sense of= statement declaration. Is that right? Why is that done this way?
=A0=A0=A0=A0=A0 Next I thought there could be some means to explicitly say,= that some parts of the lower configuration level fit for me and therefore = ease my life a little. Let say I have ResultMap statement in XML configurat= ion and 95% of its properties is fine by convention, but I need only to spe= cify more single property or declare association / collection mapping. In t= hat case I have to state all properties in order to alter the single one th= at is needed to be extra taken care of (or at least these are my findings f= rom the tests I wrote). What I really want to say is: use convention to all= properties except those that I explicitly configure in XML - that is not p= ossible, is it?

=A0 2) annotations
=A0=A0=A0=A0=A0 Another unpleasant surpris= e was, that I am not able to get along with annotations to specify <coll= ection> mapping - annotation @Collection is missing. Also @Association i= s not present - but as I discovered, it's possible to write @Result ann= otations in the way that associated object gets mapped. In documentation I = found a statement, that annotations in Java aren't powerfull enough to = make some things possible, but I can't make up why @Collection annotati= on is not possible to be made.

=A0 3) combination of XML and annotations
=A0=A0=A0=A0=A0 I t= ried combination of XML and annotations (due to lack of @Collection annotat= ion) to specify @Select annotation but specify output as a ResultMap mappin= g in the XML configuration. But that's not possible too. Mixing configu= ration from annotations and XML is not possible in any way I guess. Ok, but= is there any way how to reuse my annotations, to get the same behaviour as= reusing ResultMap mapping in different statements of XML configuration?!
=A0 4) automatic SQL implementation
=A0=A0=A0=A0=A0 I didn= 9;t find any piece of this functionality. May I take it, that this was comp= letely discarded?

=A0 5) annotations and dynamic SQL
=A0= =A0=A0=A0=A0 Finally I didn't find any clue how to use dynamic SQL in a= nnotations. Does that mean that @SelectProviders are the only way how to ma= ke dynamic queries by the Java code?

=A0=A0 Thanks for your time and answers I can use in my presentation if= anyone asks. Please, don't be offended by my questions, generally I th= ink iBatis is a great DAO framework.

Cheers Jan

--
--------------------------------------------------------------
Ing. Jan = Novotn=FD
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@=
http://blog.novoj.n= et
My=B9lenky dne otce Fura
--------------------------------------------------------------

--00148534b5b06a97ef047fe20917--