ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: Handle resultset manually
Date Thu, 13 Oct 2005 11:04:13 GMT
Hi,

You could use the TypeHandlerCallback-interface.

sqlmap:

<resultMap id="myResultMap" class="myClass">
  <result column="myColumn" property="myProperty"
typeHandler="MyHandlerCallback"/>
</resultMap>

MyHandlerCallback.java:

class MyHandlerCallback implements TypeHandlerCallback {
  ...

  public Object getResult(ResultGetter getter) throws SQLException {
	ResultSet rs = getter.getResultSet();
	MyCustomResult foo = doSomethingWithResultSet(rs);
	return foo;
  }

  public MyCustomResult doSomethingWithResultSet(ResultSet rs) {
    ...
    return null;
  }
  ...
}

That should work, never used it though...

Niels

-----Original Message-----
From: Oleg Shpak [mailto:oleg@rap-x.com] 
Sent: donderdag 13 oktober 2005 12:22
To: user-java@ibatis.apache.org
Subject: Handle resultset manually

Hi,

I really like all the stuff iBatis does, including the easy way of 
creating dynamic SQL statements.
But rarely I need to handle resultsets manually. Unfortunately resultMap

tag functionality is not enough sometimes
Currently I have to create a data holder class which captures the 
resultset data, later I post process the returned list.
I'm aware of RowHandler interface, but it solves a different kind of 
problem.

Could you please advise me what is the best currently possible solution 
for cases where resultMap tag functionality is not enough?
Can I work with the returned resultset directly?

Regards,
Oleg

Mime
View raw message