• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iBatis and Java 5...

 
hernan silberman
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another one for Clinton, Brandon & Larry,

I've been really enjoying the new Java 5 features lately and I'm amazed at how they've improved various open source toolkits. JUnit especially--the new annotations are simply amazing and make test driven development easy (and fun!).

I've seen Spring and Hibernate take advantage of annotations and generics and I'm wondering if there are plans to use these in iBatis. I can see how iBatis might leverage generics, though I'm not sure how much that would buy me since I don't mind casting what iBatis queries give me to List<MyType>.

I'm wondering what the plans are for annotations which seem to have really suped up Junit, Spring and Hibernate, and possibly other Java 5 features, if any.

thnx...
Hernan
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was some discussion about this on the ibatis mailing list. JDBC4 is going to have annotation support but it's kind of odd. Putting SQL in an annotation? Maybe for a simple select or insert, but queries can be very complex and LONG. So it actually makes your source code worse.

In the same manner, annotizing ibatis mappings would prove worse, IMHO, than just leaving them in the XML file. I don't believe you gain anything by this.
 
Clinton Begin
author
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, the JDBC Ease-of-Development features have been dropped from JDK 6. I'll spare you all my rants about how bad Java 5 is... (list available upon request).

That said, there are certainly a lot of opportunities to leverage annotations, generics and of course autoboxing will make parameters a lot cleaner!

I've actually been working on an unofficial spike of a Java 5 support JAR for iBATIS 2.x. It takes an approach that accepts 4 kinds of configuration:

1) Convention
2) Annotation
3) XML
4) Java API

It acts like a fallthrough chain of responsibility where basically everything is configured by convention to start, then annotations can override the conventions, XML can override the annotation and the Java API obviously can override anything.

It's pretty cool actually, and reduces or eliminates a lot of configuration. Unfortunately it's also a lot of work to get this out! But the potential is definitely there.

Beyond just simple configuration benefits, generics will allow us to make smart bindings to static APIs that make working with iBATIS a lot cleaner. So instead of calling:

Customer c = (Customer)sqlMapClient.queryForObject("getCustomer", 1);

You'd call:

Customer c = customerMapper.getCustomer(1);

Like magic...

I'll leave it there and say more if and when this ever gets implemented...

Cheers,
Clinton

PS: We've done interface binding before, a long time ago, even before the JDBC EoD stuff was announced.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Clinton Begin:
Actually, the JDBC Ease-of-Development features have been dropped from JDK 6. I'll spare you all my rants about how bad Java 5 is... (list available upon request).


Interesting. I wasn't aware. I'd love that list though.

Could you give an example of the kind of annotations you are talking about? I can't think of anything off the top of my head that I'd prefer in an annotation over an XML mapping. That isn't to say I prefer XML to annotations in all cases. I've been using Stripes for my j2ee framework and it only uses annotations for it's configuration and I love it. No XML.

But from how I've used iBatis, it's not clear to me on how annotating XML mappings is beneficial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic