ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott.Smi...@L-3com.com
Subject TypeHandlerCallback for multiple columns
Date Tue, 14 Jul 2009 16:29:39 GMT
I have a tricky TypeHandlerCallback problem in Java 1.6 with iBatis 2.3
and postgresql 8.3:

*         I have a java class that consists of 2 fields, duration (int)
and units (a java-5-style enum).  The fields are final, so they must be
set in the constructor (no setters).

*         I need to construct one of these objects from 2 database
columns as part of the result map for a larger composite class.

 

I have combed through the iBatis documentation, including the wiki and
archives, and did find a couple of items that looked relevant, but none
actually helped.

 

*         I found documentation indicating that I could add a
<constructor/> element to a result set.  That documentation turned out
to be strictly for iBatis with .Net, but I tried it anyway.  The
resulting sqlmap could not be parsed.

*         The standard ibatis documentation, and an archived mail
message led me to believe that I could specify multiple columns in a
<result/> tag, but when I attempt this, I get an exception stating that
"no column with the name {duration,units} exists in the result set".

*         I thought perhaps I might be able to utilize the woefully
undocumented ResultGetter.getObject(Map) method to get multiple values
out of the ResultGetter in my type handler, but that generates an
exception from postgre that "Jdbc4ResultSet.getObjectImpl(int,Map) is
not yet implemented".  (As my hope was to be able to use this in
conjunction with specifying multiple columns, which already failed, this
is perhaps a moot point.)

 

The only options I have come across that work are

*         Modify the class so that the fields are not final, then they
can be set separately.  This violates a constraint of the project I am
working on.

*         Use the ResultGetter.getResultSet() method to access the
underlying result set from the type handler, so I can access both
columns simultaneously.  This presents problems because it requires me
to insert information about the actual data table into the java code for
the type handler, and because the columns may not have the exact same
names in different tables, requiring table-specific type handlers.

 

Does anybody have a good working solution for this situation?

 

Thanks

 


Mime
View raw message