You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Bing Zou <xi...@gmail.com> on 2005/07/22 19:48:53 UTC
Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Hi all,
We are doing a lot of refactoring and one issue came up was that
moving JavaBean, renaming or overloading setter/getters could break
the existing iBATIS queries. But we have to wait till runtime and test
every related functionality for that purpose.
I am wondering whether there is a way we could perform this kind of
validation in advance?
Thanks.
Bing
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Clinton Begin <cl...@gmail.com>.
*cough* unit tests *cough*
*hah* need them anyway *choo*
Cheers, ;-)
Clinton
On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
>
> An easy solution pops up to my head is to write a simple class that
> scan through all the xml files in sql-map-config.xml and use
> reflection to verify the getter/setters etc.
>
> I hope the future iBATIS release can include such a util.
>
> Thanks.
> Bing
>
> On 7/22/05, Larry Meadors <la...@gmail.com> wrote:
> > Usually simply loading the sql map shows much of that.
> >
> > There is a property that is earmarked to show more info, but it has yet
> to
> > be implemented.
> >
> > This has been at the top of my wish list for some time now, too.
> >
> > Just too much other crap in front of it I guess. ;-)
> >
> > Larry
> >
> >
> >
> > On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > > Yes, I read that thread. Unfortunately, there don't exist many unit
> > > tests that directly test the correctness of the iBATIS queries. All
> > > the queries have been approved by DBA and are supposed to be correct.
> > > Actually, my question is not to test the correctness of the iBATIS
> > > queries, but to test these:
> > >
> > > 1. Whether the getter/setter methods of the resultClass has changed.
> > > 2. Whether the ParameterClass, resultClass has been renamed.
> > > 3. Whether the setter/getters are overloaded.
> > > ...
> > >
> > > Thanks a lot.
> > > Bing
> > > On 7/22/05, Ed Griebel <ed...@gmail.com> wrote:
> > > > This exact question was asked yesterday or Wednesday, you can
> probably
> > > > find the thread in the archive.
> > > >
> > > > -ed
> > > >
> > > > On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > > > > Hi all,
> > > > >
> > > > > We are doing a lot of refactoring and one issue came up was that
> > > > > moving JavaBean, renaming or overloading setter/getters could
> break
> > > > > the existing iBATIS queries. But we have to wait till runtime and
> test
> > > > > every related functionality for that purpose.
> > > > >
> > > > > I am wondering whether there is a way we could perform this kind
> of
> > > > > validation in advance?
> > > > >
> > > > > Thanks.
> > > > > Bing
> > > > >
> > > >
> > >
> >
> >
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Bing Zou <xi...@gmail.com>.
An easy solution pops up to my head is to write a simple class that
scan through all the xml files in sql-map-config.xml and use
reflection to verify the getter/setters etc.
I hope the future iBATIS release can include such a util.
Thanks.
Bing
On 7/22/05, Larry Meadors <la...@gmail.com> wrote:
> Usually simply loading the sql map shows much of that.
>
> There is a property that is earmarked to show more info, but it has yet to
> be implemented.
>
> This has been at the top of my wish list for some time now, too.
>
> Just too much other crap in front of it I guess. ;-)
>
> Larry
>
>
>
> On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > Yes, I read that thread. Unfortunately, there don't exist many unit
> > tests that directly test the correctness of the iBATIS queries. All
> > the queries have been approved by DBA and are supposed to be correct.
> > Actually, my question is not to test the correctness of the iBATIS
> > queries, but to test these:
> >
> > 1. Whether the getter/setter methods of the resultClass has changed.
> > 2. Whether the ParameterClass, resultClass has been renamed.
> > 3. Whether the setter/getters are overloaded.
> > ...
> >
> > Thanks a lot.
> > Bing
> > On 7/22/05, Ed Griebel <ed...@gmail.com> wrote:
> > > This exact question was asked yesterday or Wednesday, you can probably
> > > find the thread in the archive.
> > >
> > > -ed
> > >
> > > On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > > > Hi all,
> > > >
> > > > We are doing a lot of refactoring and one issue came up was that
> > > > moving JavaBean, renaming or overloading setter/getters could break
> > > > the existing iBATIS queries. But we have to wait till runtime and test
> > > > every related functionality for that purpose.
> > > >
> > > > I am wondering whether there is a way we could perform this kind of
> > > > validation in advance?
> > > >
> > > > Thanks.
> > > > Bing
> > > >
> > >
> >
>
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Larry Meadors <la...@gmail.com>.
Usually simply loading the sql map shows much of that.
There is a property that is earmarked to show more info, but it has yet to
be implemented.
This has been at the top of my wish list for some time now, too.
Just too much other crap in front of it I guess. ;-)
Larry
On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
>
> Yes, I read that thread. Unfortunately, there don't exist many unit
> tests that directly test the correctness of the iBATIS queries. All
> the queries have been approved by DBA and are supposed to be correct.
> Actually, my question is not to test the correctness of the iBATIS
> queries, but to test these:
>
> 1. Whether the getter/setter methods of the resultClass has changed.
> 2. Whether the ParameterClass, resultClass has been renamed.
> 3. Whether the setter/getters are overloaded.
> ...
>
> Thanks a lot.
> Bing
> On 7/22/05, Ed Griebel <ed...@gmail.com> wrote:
> > This exact question was asked yesterday or Wednesday, you can probably
> > find the thread in the archive.
> >
> > -ed
> >
> > On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > > Hi all,
> > >
> > > We are doing a lot of refactoring and one issue came up was that
> > > moving JavaBean, renaming or overloading setter/getters could break
> > > the existing iBATIS queries. But we have to wait till runtime and test
> > > every related functionality for that purpose.
> > >
> > > I am wondering whether there is a way we could perform this kind of
> > > validation in advance?
> > >
> > > Thanks.
> > > Bing
> > >
> >
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Bing Zou <xi...@gmail.com>.
Yes, I read that thread. Unfortunately, there don't exist many unit
tests that directly test the correctness of the iBATIS queries. All
the queries have been approved by DBA and are supposed to be correct.
Actually, my question is not to test the correctness of the iBATIS
queries, but to test these:
1. Whether the getter/setter methods of the resultClass has changed.
2. Whether the ParameterClass, resultClass has been renamed.
3. Whether the setter/getters are overloaded.
...
Thanks a lot.
Bing
On 7/22/05, Ed Griebel <ed...@gmail.com> wrote:
> This exact question was asked yesterday or Wednesday, you can probably
> find the thread in the archive.
>
> -ed
>
> On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > Hi all,
> >
> > We are doing a lot of refactoring and one issue came up was that
> > moving JavaBean, renaming or overloading setter/getters could break
> > the existing iBATIS queries. But we have to wait till runtime and test
> > every related functionality for that purpose.
> >
> > I am wondering whether there is a way we could perform this kind of
> > validation in advance?
> >
> > Thanks.
> > Bing
> >
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Ron Grabowski <ro...@yahoo.com>.
Yes, I agree. Having a tool to scan through all the sql map xml files
and check that properties have been typed correctly and are
readable/writeable would be a time saver. I usually don't find out I
made a typo until runtime :-/
--- Ed Griebel <ed...@gmail.com> wrote:
> And it sounds like this is strictly to determine if the XML is
> well-formed and valid. The trick is determining if the XML matches
> the
> DB schema, which is a far more difficult (infinitely more difficult?)
> problem.
>
> -ed
>
> On 7/22/05, Ron Grabowski <ro...@yahoo.com> wrote:
> > In the 1.x releases, there was a XmlSqlMapValidator class that
> could
> > validate the maps at compile time:
> >
> > ibatis_db_guide-1-2-9.pdf
> > "
> > Validation
> >
> > While your developing your application, it is probably quite
> > inconvenient to start up your app server just to test your SQL
> Maps.
> > For this reason, a separate utility is provided for validating SQL
> > Maps. This validator can be run from within the Ant build tool for
> > simple build-time SQL Map validation. You can specify as many SQL
> map
> > config files as you like. By default the validator will look for
> the
> > files
> > relative to the classpath. If you want to specify a full file path,
> you
> > can do so by simply prefixing the resource path with "file:". Here
> are
> > a few examples:
> >
> > java com.ibatis.db.sqlmap.XmlSqlMapValidator SqlMapConfig1.xml
> > SqlMapConfig2.xml
> > java com.ibatis.db.sqlmap.XmlSqlMapValidator
> > com/domain/app/sql/SqlMapConfig1.xml
> > java com.ibatis.db.sqlmap.XmlSqlMapValidator
> > file:C:/devt/sql/SqlMapConfig1.xml
> >
> > As mentioned, you can also run the validator from within an Ant
> build
> > script. Here's an example target
> > using the <java> task:
> > <target name="validateMaps" depends="compile">
> > <java classpathref="classpath"
> > classname="com.ibatis.db.sqlmap.XmlSqlMapValidator" >
> > <arg value="examples/sqlmap/maps/SqlMapConfigExample.xml"/>
> > <arg value="file:C:/devt/sql/SqlMapConfig1.xml"/>
> > </java>
> > </target>
> >
> > Note! The validator currently does not throw an exception in the
> case
> > of errors. Watch the build log!
> > "
> >
> > I don't think it exists anymore.
> >
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Ed Griebel <ed...@gmail.com>.
And it sounds like this is strictly to determine if the XML is
well-formed and valid. The trick is determining if the XML matches the
DB schema, which is a far more difficult (infinitely more difficult?)
problem.
-ed
On 7/22/05, Ron Grabowski <ro...@yahoo.com> wrote:
> In the 1.x releases, there was a XmlSqlMapValidator class that could
> validate the maps at compile time:
>
> ibatis_db_guide-1-2-9.pdf
> "
> Validation
>
> While your developing your application, it is probably quite
> inconvenient to start up your app server just to test your SQL Maps.
> For this reason, a separate utility is provided for validating SQL
> Maps. This validator can be run from within the Ant build tool for
> simple build-time SQL Map validation. You can specify as many SQL map
> config files as you like. By default the validator will look for the
> files
> relative to the classpath. If you want to specify a full file path, you
> can do so by simply prefixing the resource path with "file:". Here are
> a few examples:
>
> java com.ibatis.db.sqlmap.XmlSqlMapValidator SqlMapConfig1.xml
> SqlMapConfig2.xml
> java com.ibatis.db.sqlmap.XmlSqlMapValidator
> com/domain/app/sql/SqlMapConfig1.xml
> java com.ibatis.db.sqlmap.XmlSqlMapValidator
> file:C:/devt/sql/SqlMapConfig1.xml
>
> As mentioned, you can also run the validator from within an Ant build
> script. Here's an example target
> using the <java> task:
> <target name="validateMaps" depends="compile">
> <java classpathref="classpath"
> classname="com.ibatis.db.sqlmap.XmlSqlMapValidator" >
> <arg value="examples/sqlmap/maps/SqlMapConfigExample.xml"/>
> <arg value="file:C:/devt/sql/SqlMapConfig1.xml"/>
> </java>
> </target>
>
> Note! The validator currently does not throw an exception in the case
> of errors. Watch the build log!
> "
>
> I don't think it exists anymore.
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Ron Grabowski <ro...@yahoo.com>.
In the 1.x releases, there was a XmlSqlMapValidator class that could
validate the maps at compile time:
ibatis_db_guide-1-2-9.pdf
"
Validation
While your developing your application, it is probably quite
inconvenient to start up your app server just to test your SQL Maps.
For this reason, a separate utility is provided for validating SQL
Maps. This validator can be run from within the Ant build tool for
simple build-time SQL Map validation. You can specify as many SQL map
config files as you like. By default the validator will look for the
files
relative to the classpath. If you want to specify a full file path, you
can do so by simply prefixing the resource path with file:. Here are
a few examples:
java com.ibatis.db.sqlmap.XmlSqlMapValidator SqlMapConfig1.xml
SqlMapConfig2.xml
java com.ibatis.db.sqlmap.XmlSqlMapValidator
com/domain/app/sql/SqlMapConfig1.xml
java com.ibatis.db.sqlmap.XmlSqlMapValidator
file:C:/devt/sql/SqlMapConfig1.xml
As mentioned, you can also run the validator from within an Ant build
script. Heres an example target
using the <java> task:
<target name="validateMaps" depends="compile">
<java classpathref="classpath"
classname="com.ibatis.db.sqlmap.XmlSqlMapValidator" >
<arg value="examples/sqlmap/maps/SqlMapConfigExample.xml"/>
<arg value="file:C:/devt/sql/SqlMapConfig1.xml"/>
</java>
</target>
Note! The validator currently does not throw an exception in the case
of errors. Watch the build log!
"
I don't think it exists anymore.
--- Ed Griebel <ed...@gmail.com> wrote:
> This exact question was asked yesterday or Wednesday, you can
> probably
> find the thread in the archive.
>
> -ed
>
> On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> > Hi all,
> >
> > We are doing a lot of refactoring and one issue came up was that
> > moving JavaBean, renaming or overloading setter/getters could break
> > the existing iBATIS queries. But we have to wait till runtime and
> test
> > every related functionality for that purpose.
> >
> > I am wondering whether there is a way we could perform this kind of
> > validation in advance?
> >
> > Thanks.
> > Bing
> >
>
Re: Is there a way to validate parameterClass and resultClass for each ibatis query before runtime?
Posted by Ed Griebel <ed...@gmail.com>.
This exact question was asked yesterday or Wednesday, you can probably
find the thread in the archive.
-ed
On 7/22/05, Bing Zou <xi...@gmail.com> wrote:
> Hi all,
>
> We are doing a lot of refactoring and one issue came up was that
> moving JavaBean, renaming or overloading setter/getters could break
> the existing iBATIS queries. But we have to wait till runtime and test
> every related functionality for that purpose.
>
> I am wondering whether there is a way we could perform this kind of
> validation in advance?
>
> Thanks.
> Bing
>