Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

iBATIS: Compile-time checking

 
David Demner
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was checking out the Java Tutorial on the iBATIS site and noticed there doesn't seem to be compile-time checking of the iBATIS layer. For example,

sqlMap.update(�updatePerson�, person);

This doesn't guarantee the "updatePerson" exists, is valid for the 'person' object, etc, etc. Is there an alternate way of doing this (ie: maybe it was 'dumbed-down' for the tutorial)?

Thanks,

David
 
Clinton Begin
author
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iBATIS 1.x did have a build-time check. However, our belief now is that you should be unit testing anyway. Even if we verified that the name of the mapped statement existed, and perhaps even that the parameter was of the correct type, you've verified very little about your code.

You should be writing unit tests for your mapped statements, just like you would for other public interfaces. Because they're touching a database, we often call these persistence or (more broadly) integration tests. But you can use a simple unit testing framework like JUnit or TestNG to achieve this.

See JPetStore for examples on unit testing iBATIS. Notice that HSQLDB comes in handy.

Cheers,
Clinton
 
Dhananjay Patkar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
You raised good concern, but Please have a look @ iBatis 3 Whiteboard iBatis 3 has support for interface binding, thus eliminating string type query ids ,typecasting ..

Cheers,
Dhananjay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic