[jira] Commented: (IBATIS-53) Support for oracle cursors as resultsets

2006-02-09 Thread Mohamed Arif (JIRA)
[ 
http://issues.apache.org/jira/browse/IBATIS-53?page=comments#action_12365702 ] 

Mohamed Arif commented on IBATIS-53:



Hi Michael Faqan,
Thank You.

Regards,
RF

 Support for oracle cursors as resultsets
 

  Key: IBATIS-53
  URL: http://issues.apache.org/jira/browse/IBATIS-53
  Project: iBatis for Java
 Type: New Feature
   Components: SQL Maps
 Reporter: Ken Katsma
 Priority: Minor
  Fix For: 2.1.0
  Attachments: SqlExecutor.java, SqlExecutor.java, SqlExecutor.java, 
 SqlExecutor.java, showcase.txt, showcase_storedprocedure.txt, 
 showcase_storedprocedure1.txt

 iBatis doesn't currently support result sets from functions in Oracle.  A 
 modification to SQLExecutor as detailed below can add the necessary support.  
 However, it requires a hard-coded check for an Oracle driver.  A better 
 option would be to supply a factory for alternate SQLExecutor's for different 
 dialects.  This would allow for any future database specific customization as 
 well.
 The code change is in SQLExecutor.executeQueryProcedure (see comments):
  public void executeQueryProcedure(RequestScope request, Connection conn, 
 String sql, Object[] parameters,
int skipResults, int maxResults, 
 RowHandlerCallback callback)
  throws SQLException {
ErrorContext errorContext = request.getErrorContext();
errorContext.setActivity(executing query procedure);
errorContext.setObjectId(sql);
CallableStatement cs = null;
ResultSet rs = null;
  try {
  errorContext.setMoreInfo(Check the SQL Statement (preparation 
 failed).);
  cs = conn.prepareCall(sql);
  ParameterMap parameterMap = request.getParameterMap();
  ParameterMapping[] mappings = parameterMap.getParameterMappings();
  errorContext.setMoreInfo(Check the output parameters (register output 
 parameters failed).);
  registerOutputParameters(cs, mappings);
  errorContext.setMoreInfo(Check the parameters (set parameters 
 failed).);
  parameterMap.setParameters(request, cs, parameters);
  errorContext.setMoreInfo(Check the statement (update procedure 
 failed).);
  // 
  // Code changes below
  // 
  if 
 (conn.getMetaData().getDatabaseProductName().equalsIgnoreCase(Oracle))
  {
   // If in oracle then execute instead of executeQuery
  boolean b = cs.execute();
  errorContext.setMoreInfo(In Oracle query mode.);
  errorContext.setMoreInfo(Check the output parameters (retrieval of 
 output parameters failed).);
   // Get the output parameters first, instead of last 
  retrieveOutputParameters(cs, mappings, parameters);
   // Then find the resultset and handle it
 for (int i=0;iparameters.length;i++)
  {
  if (parameters[i] instanceof ResultSet)
  {
  rs = (ResultSet) parameters[i];
  break;
  }
  }
  errorContext.setMoreInfo(Check the results (failed to retrieve 
 results).);
  handleResults(request, rs, skipResults, maxResults, callback);
  }
  //
  // Non-oracle..original code
  else
  {
   
  errorContext.setMoreInfo(In non-Oracle mode.);
  rs = cs.executeQuery();
errorContext.setMoreInfo(Check the results (failed to retrieve 
 results).);
handleResults(request, rs, skipResults, maxResults, callback);
errorContext.setMoreInfo(Check the output parameters (retrieval of 
 output parameters failed).);
retrieveOutputParameters(cs, mappings, parameters);
  }
  } finally {
  try {
closeResultSet(rs);
  } finally {
closeStatement(cs);
  }
} 
 An example mapping looks like:
  parameterMap id=clientParameters class=map 
parameter property=result jdbcType=ORACLECURSOR mode=OUT/
parameter property=maxRows jdbcType=VARCHAR 
 javaType=java.lang.String mode=IN/
/parameterMap
procedure id=getClientListProc resultMap=clientResult 
 parameterMap=clientParameters
{?= call abc.CLIENT_VIEW_PKG.client_result_list_f(?)}
/procedure 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



Problem with HashMap and List

2006-02-09 Thread Ext_Friedrich, Stefan
Title: Problem with HashMap and List






Hi,


I've just encountered a big problem with my iBatis-Application. First I implemented a DOM and used it in the class=-Properties of my resultMaps. Now we decided, to change the architecture to a HashMap-Structure of the following: HashMap as some Lists as values: the Lists have HashMaps again. Here is an example of my xml-File to illustrate, what I want to do:

resultMap id=a class=java.util.HashMap

 result property=aa select=loadAA/

 result property=id column=id/

/resultMap 

select id=loadA resultMap=a

 Select id from tableA where id = 1

/select


resultMap id=aa class=java.util.HashMap

 result property=id column=id/

/resultMap 

select id=loadAA resultMap=aa

 Select id from tableA

/select


The first select returns one result -- a HashMap, the second select returns numerous results -- n HashMaps that should be mapped as a List of HashMaps.

When we implement it as a DOM and exchange the classes in the resultMaps with the ones below, the same code works fine:


class A {

 private Collection aa;

 private int id;

 //getters and setters

}


class AA {

 private int id;

}


When we try to run the application we get:


Exception in thread main org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; 

--- The error occurred in test.xml. 

--- The error occurred while applying a result map. 

--- Check the a. 

--- Check the result mapping for the 'aa' property. 

--- Cause: java.sql.SQLException: Error: executeQueryForObject returned too many results.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: 

After reviewing the sources we've come up with an explanation:


The Method BasicResultMap.getResults(RequestScope request, ResultSet rs) the targetType for further calls is set:


if (resultClass == null) {

 throw new SqlMapException(The result class was null when trying to get results for ResultMap named  + getId() + .);

} else if (Map.class.isAssignableFrom(resultClass)) {

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, Object.class);

} else if (DomTypeMarker.class.isAssignableFrom(resultClass)) {

 Class javaType = mapping.getJavaType();

 if (javaType == null) {

 javaType = DomTypeMarker.class;

 }

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, javaType);

} else {

 Probe p = ProbeFactory.getProbe(resultClass);

 Class type = p.getPropertyTypeForSetter(resultClass, mapping.getPropertyName());

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, type);

}


So, how can we get around this? If the else-Statements would be something like:


if (resultClass == null) {

 throw new SqlMapException(The result class was null when trying to get results for ResultMap named  + getId() + .);

} else if (DomTypeMarker.class.isAssignableFrom(resultClass)) {

 Class javaType = mapping.getJavaType();

 if (javaType == null) {

 javaType = DomTypeMarker.class;

 }

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, javaType);

} else if (Map.class.isAssignableFrom(resultClass)) {

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, Object.class);

} else {

 Probe p = ProbeFactory.getProbe(resultClass);

 Class type = p.getPropertyTypeForSetter(resultClass, mapping.getPropertyName());

 columnValues[i] = getNestedSelectMappingValue(request, rs, mapping, type);

}


Our problem would be solvalbe implementing a DummyDO-Class:



class DummyDO extends HashMap implements DomTypeMarker



BUT, due to the order of the else-Statements this doesn't work and again, targetType is set to java.lang.Object and later, the getQueryForObject-Method is called.

How can we get around this?


Stefan Friedrich





[jira] Commented: (IBATIS-156) configured type handler not used in insert

2006-02-09 Thread Mohamed Arif (JIRA)
[ 
http://issues.apache.org/jira/browse/IBATIS-156?page=comments#action_12365722 ] 

Mohamed Arif commented on IBATIS-156:
-


Hi,
   I am trying to work on TypeHandler as one of the column returned by my 
ResultSet is of type CHAR.

   I am getting the following exception w.r.t TypeHandler,

--- The error occurred in Policy.xml.  
--- The error occurred while applying a result map.  
--- Check the Policy.customerPolicyResult.  
--- Check the result mapping for the 'attValue' property.  
--- Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be 
found to map the property 'attValue' to the column 'POLICY_ATTRIBUTE_VALUE'.  
One or both of the types, or the combination of types is not supported.; nested 
exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in Policy.xml.  
--- The error occurred while applying a result map.  
--- Check the Policy.customerPolicyResult.  
--- Check the result mapping for the 'attValue' property.

   Here are the configuration details,

My Stored Procedure is,
CREATE OR REPLACE PROCEDURE PR_RS_GET_POLICY_DETAILS (
PA_OUT_RETCURSOR  OUT  RS_GENERAL.REFCURSOR
)
AS

BEGIN
OPEN PA_OUT_RETCURSOR FOR
SELECT   DET.CUSTOMER_ID as CUSTOMER_ID,
 DET.POLICY_ID as POLICY_ID,
 DET.POLICY_ATTRIBUTE_VALUE as POLICY_ATTRIBUTE_VALUE,
 EXCEP.RELATED_CUSTOMER_ID as RELATED_CUSTOMER_ID
FROM RS_POLICY_DET DET,
 RS_POLICY_EXCEPTIONLIST_DET EXCEP
WHEREDET.POLICY_ID = EXCEP.POLICY_ID(+)
AND  DET.CUSTOMER_ID = EXCEP.CUSTOMER_ID(+)
ORDER BY DET.CUSTOMER_ID,
 DET.POLICY_ID;
END PR_RS_GET_POLICY_DETAILS;
/


*  Here the column POLICY_ATTRIBUTE_VALUE is of type CHAR.

My SQLMapConfig file is as follow,
*

?xml version=1.0 encoding=UTF-8?
!DOCTYPE sqlMapConfig
PUBLIC -//iBATIS.com//DTD SQL Map Config 2.0//EN
http://www.ibatis.com/dtd/sql-map-config-2.dtd;
sqlMapConfig

typeAlias alias=charTypeHandler 
type=com.rss.rs.common.dao.ibatisImpl.CharTypeHandlerCallback/

typeHandler javaType=java.lang.String jdbcType=CHAR 
callback=charTypeHandler/

sqlMap resource=Policy.xml/

/sqlMapConfig

***
My SQLMap file Policy.xml ,

?xml version=1.0 encoding=UTF-8?
!DOCTYPE sqlMap
PUBLIC -//iBATIS.com//DTD SQL Map 2.0//EN
http://www.ibatis.com/dtd/sql-map-2.dtd;

sqlMap namespace=Policy

typeAlias alias=policyRS type=com.rsa.rcas.common.dto.PolicyRS/

resultMap id=customerPolicyResult class=policyRS
result property=customerID column=CUSTOMER_ID /
result property=policyID column=POLICY_ID /
result property=attValue column=POLICY_ATTRIBUTE_VALUE 
jdbcType=CHAR/
result property=relatedCustomerid column=RELATED_CUSTOMER_ID /
/resultMap

parameterMap id=policySPInput class=map 
parameter property=PA_OUT_RETCURSOR jdbcType=ORACLECURSOR 
mode=OUT/  
/parameterMap

procedure id=getPolicyDetail parameterMap=policySPInput 
resultMap=customerPolicyResult
{ call PR_RCAS_GET_POLICY_DETAILS (?) }
/procedure

/sqlMap

***

My TypeHandler class CharTypeHandlerCallback.java,

import java.sql.SQLException;
import java.sql.Types;

import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;

public class CharTypeHandlerCallback implements TypeHandlerCallback {

public Object getResult(ResultGetter getter) throws SQLException {
System.out.println(Inside getResult);
if(getter.wasNull())
return null;

 return getter.getString();
   }

public void setParameter(ParameterSetter setter, Object parameter) 
throws SQLException {
System.out.println(Inside setParameter);
if (parameter == null) {
setter.setNull(Types.CHAR);
} else {
setter.setString((String)parameter.toString());
}
}

public Object valueOf(String s) {
System.out.println(Inside valueOf);
return s;
   }

}
*
ResultMap class PolicyRS.java

public class PolicyRS {

private long customerID;
private long policyID;
private char attValue;
private long relatedCustomerid;

public char getAttValue() {
return attValue;
}
public void setAttValue(char attValue) {
this.attValue = attValue;
}
public long getCustomerID() {
return customerID;
}
public void setCustomerID(long customerID) {
this.customerID = 

Re: support

2006-02-09 Thread Larry Meadors
What is it that you are trying to accomplish with this?

Larry


On 2/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Hello developers

 Can you support getting context (id) informations within a DAO impl
 instance?

 There is only a access to the daoManager instance that is set in the
 constructor of each DAO implementation in
 class XMLDaoManagerBuilder in method private DaoImpl parseDao(Element
 element, StandardDaoManager daoManager, DaoContext daoContext)
 {...Constructor constructor = daoClass.getConstructor(new
 Class[]{DaoManager.class});...}

 If I have access to the context (id) I can call other DAO impls within a DAO
 impl with the same context id.

 I think there are many ways to support that:

 1. add a second constructor to DAO impls that sets the DaoContext in
 addition to the DaoManager (so I can call the method
 this.daoManager.getDao(DAO_name.class, this.daoContext.getId())
 2. add a method to DaoManager that returns the context id for current DAO
 instance (so I can call the method this.daoManager.getDao(DAO_name.class,
 requested_context_id)
 3. add a method to DaoManager that returns a DAO instance within the same
 context of current DAO instance (like
 this.daoManager.getDao(DAO_name.class, this)

 What do you think of this?

 Best regards
 Manuel Rädle
  Entwicklung

  PRÜFTECHNIK Condition Monitoring
  Franz-Bayer-Straße 14
  D-88213 Ravensburg
  http://www.pruftechnik.com
  Tel: +49 (0)751 76956-12
  Fax: +49 (0)751 76956-79

 -


Re: support

2006-02-09 Thread Manuel . Raedle

Hello,

I will have access to other DAO instances
within a DAO instance to have access to other data infos. Therefore I need
the context id of current DAO instance.

For example:

I have a UserSqlMapDao and a GroupSqlMapDao.

I support requesting users with group
infos. Therefore I will request all groups from the GroupSqlMapDao within
the UserSqlMapDao class.
I support also more than one database
so I need the context id.

Best regards
Manuel 

PRÜFTECHNIK Condition Monitoring 
Franz-Bayer-Straße 14
D-88213 Ravensburg
http://www.pruftechnik.com
Tel: +49 (0)751 76956-12
Fax: +49 (0)751 76956-79

-





Larry Meadors [EMAIL PROTECTED]

Sent by: [EMAIL PROTECTED]
09.02.2006 16:44



Please respond to
dev@ibatis.apache.org





To
dev@ibatis.apache.org


cc



Subject
Re: support








What is it that you are trying to accomplish with
this?

Larry


On 2/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:

 Hello developers

 Can you support getting context (id) informations within a DAO impl
 instance?

 There is only a access to the daoManager instance that is set in the
 constructor of each DAO implementation in
 class XMLDaoManagerBuilder in method private DaoImpl
parseDao(Element
 element, StandardDaoManager daoManager, DaoContext daoContext)
 {...Constructor constructor = daoClass.getConstructor(new
 Class[]{DaoManager.class});...}

 If I have access to the context (id) I can call other DAO impls within
a DAO
 impl with the same context id.

 I think there are many ways to support that:

 1. add a second constructor to DAO impls that sets the DaoContext
in
 addition to the DaoManager (so I can call the method
 this.daoManager.getDao(DAO_name.class, this.daoContext.getId())
 2. add a method to DaoManager that returns the context id for current
DAO
 instance (so I can call the method this.daoManager.getDao(DAO_name.class,
 requested_context_id)
 3. add a method to DaoManager that returns a DAO instance within the
same
 context of current DAO instance (like
 this.daoManager.getDao(DAO_name.class, this)

 What do you think of this?

 Best regards
 Manuel Rädle
 Entwicklung

 PRÜFTECHNIK Condition Monitoring
 Franz-Bayer-Straße 14
 D-88213 Ravensburg
 http://www.pruftechnik.com
 Tel: +49 (0)751 76956-12
 Fax: +49 (0)751 76956-79

 -



Re: Oracle ref cursors

2006-02-09 Thread Clinton Begin
So the assumptions made here are: * There can be only one out parameter of type ResultSet * The default result set (possibly returned from a SELECT) is lost, as it's overidden by the ResultSet parameter.
Seems a bit hackey, but I'm interested in everyone else's opinion. ClintonOn 2/9/06, Sven Boden [EMAIL PROTECTED]
 wrote:I've been playing a bit with Michael Fagan's patch for supporting
ResultMaps using Oracle ref cursors. Sometimes I'm also a bit fond ofpushing as much functionality as possible in Oracle procedures and onlyexposing a ref cursor to the (C) applications.The patch works but having ORACLECURSOR in the iBATIS code puts me a bit
off. So I made some small cosmetic changes... what about the following:- Michael Fagan's patch (now already to be redone because of otherchanges in 2.1.7)- With following changes:# Adding javaType=
java.sql.ResultSet to the parameterMapparameterMap id=single-rs class=map parameter property=in1 jdbcType=intjavaType=java.lang.Integer
 mode=IN/parameter property=output1 jdbcType=ORACLECURSORjavaType=java.sql.ResultSet mode=OUT//parameterMap
# doing the ResultSet extraction as follows (hardcoding ResultSetinstead of ORACLECURSOR).if (mapping.isOutputAllowed()) { if (java.sql.ResultSet.equalsIgnoreCase(
mapping.getJavaTypeName()) ){ResultSet rs = (ResultSet) cs.getObject( i + 1 );# In the TypeHandlerFactory a shortcut cursor could be made forjava.sql.ResultSet
The above change would not put something Oracle only in iBATIS sourcecode, it would make the SQLMap still dependent on Oracle because ofORACLECURSOR but I don't see this as a big problem (as soon as you use
SQL dialect in the SqlMaps you're also dependent upon a database).As long as an other database supports a type for cursor it can use theimplementation above. Or is there something I'm missing, which could
come back to haunt us?People using the current patch should then only addjavaType=java.sql.ResultSet to their maps.Regards,Sven Boden


Re: Oracle ref cursors

2006-02-09 Thread Sven Boden


There can be more than 1 out result sets, Michael's testcases on the 
wiki show that.


Will check the second bullet tomorrow, we can probably find a way around 
it it should also be just a resultset (but I vaguely remember some 
problems with it from past experiments).


Sven

Clinton Begin wrote:


So the assumptions made here are:

 * There can be only one out parameter of type ResultSet
 * The default result set (possibly returned from a SELECT) is lost, as
it's overidden by the ResultSet parameter.

Seems a bit hackey, but I'm interested in everyone else's opinion.

Clinton

On 2/9/06, Sven Boden [EMAIL PROTECTED] wrote:
 


I've been playing a bit with Michael Fagan's patch for supporting
ResultMaps using Oracle ref cursors. Sometimes I'm also a bit fond of
pushing as much functionality as possible in Oracle procedures and only
exposing a ref cursor to the (C) applications.

The patch works but having ORACLECURSOR in the iBATIS code puts me a bit
off. So I made some small cosmetic changes... what about the following:

- Michael Fagan's patch (now already to be redone because of other
changes in 2.1.7)
- With following changes:
   # Adding javaType=java.sql.ResultSet to the parameterMap
   parameterMap id=single-rs class=map 
   parameter property=in1 jdbcType=int
javaType=java.lang.Integer mode=IN/
   parameter property=output1 jdbcType=ORACLECURSOR
javaType=java.sql.ResultSet mode=OUT/
   /parameterMap

   # doing the ResultSet extraction as follows (hardcoding ResultSet
instead of ORACLECURSOR).
   
   if (mapping.isOutputAllowed()) {
  if (
java.sql.ResultSet.equalsIgnoreCase(mapping.getJavaTypeName()) )  {
 ResultSet rs = (ResultSet) cs.getObject( i + 1 );
   

   # In the TypeHandlerFactory a shortcut cursor could be made for
java.sql.ResultSet

The above change would not put something Oracle only in iBATIS source
code, it would make the SQLMap still dependent on Oracle because of
ORACLECURSOR but I don't see this as a big problem (as soon as you use
SQL dialect in the SqlMaps you're also dependent upon a database).
As long as an other database supports a type for cursor it can use the
implementation above. Or is there something I'm missing, which could
come back to haunt us?

People using the current patch should then only add
javaType=java.sql.ResultSet to their maps.

Regards,
Sven Boden


   



 





Re: Oracle ref cursors

2006-02-09 Thread Clinton Begin
Yep. I agree on the need. Just being cautious about the implementation.Cheers,ClintonOn 2/9/06, Sven Boden 
[EMAIL PROTECTED] wrote:In case anyone is interested in having a look, I uploaded the patch to
the patch to the wiki,http://opensource2.atlassian.com/confluence/oss/display/IBATIS/Oracle+REF+CURSOR+Solutions
We may need to think some other things over, but a lot of people seem toneed/want something in iBATIS to convert ResultSets from storedprocedures to maps.Sven There can be more than 1 out result sets, Michael's testcases on the
 wiki show that. Will check the second bullet tomorrow, we can probably find a way around it it should also be just a resultset (but I vaguely remember some problems with it from past experiments).
 Sven Clinton Begin wrote: So the assumptions made here are:* There can be only one out parameter of type ResultSet* The default result set (possibly returned from a SELECT) is lost, as
 it's overidden by the ResultSet parameter. Seems a bit hackey, but I'm interested in everyone else's opinion. Clinton On 2/9/06, Sven Boden 
[EMAIL PROTECTED] wrote: I've been playing a bit with Michael Fagan's patch for supporting ResultMaps using Oracle ref cursors. Sometimes I'm also a bit fond of
 pushing as much functionality as possible in Oracle procedures and only exposing a ref cursor to the (C) applications. The patch works but having ORACLECURSOR in the iBATIS code puts me a
 bit off. So I made some small cosmetic changes... what about the following: - Michael Fagan's patch (now already to be redone because of other changes in 
2.1.7) - With following changes:# Adding javaType=java.sql.ResultSet to the parameterMapparameterMap id=single-rs class=map 
parameter property=in1 jdbcType=int javaType=java.lang.Integer mode=IN/parameter property=output1 jdbcType=ORACLECURSOR
 javaType=java.sql.ResultSet mode=OUT//parameterMap# doing the ResultSet extraction as follows (hardcoding ResultSet
 instead of ORACLECURSOR).if (mapping.isOutputAllowed()) { if ( java.sql.ResultSet.equalsIgnoreCase(mapping.getJavaTypeName
()) ){ResultSet rs = (ResultSet) cs.getObject( i + 1 );# In the TypeHandlerFactory a shortcut cursor could be made for
 java.sql.ResultSet The above change would not put something Oracle only in iBATIS source code, it would make the SQLMap still dependent on Oracle because of
 ORACLECURSOR but I don't see this as a big problem (as soon as you use SQL dialect in the SqlMaps you're also dependent upon a database). As long as an other database supports a type for cursor it can use
 the implementation above. Or is there something I'm missing, which could come back to haunt us? People using the current patch should then only add
 javaType=java.sql.ResultSet to their maps. Regards, Sven Boden



Re: Oracle ref cursors

2006-02-09 Thread Clinton Begin
Hmmm...ok. Here's what I'd like to see in a solution: * No dependency upon Oracle (like you've said). * ResultSet types should be supported in both OUT parameters, as well as result set columns (ick).
 * The regular result set returned by a select statement or procedure should not be compromised.So conceivably I should be able to do something like this:---resultMap  result ... jdbcType=ResultSet useResultMap=.../
/resultMapparameterMap  parameter  jdbcType=ResultSet useResultMap=...//parameterMapproc id=blah ... ...
/List list = sqlMap.queryForList(blah, myParam);---In this case, I may have dealt with 3 result maps. One to deal with the OUT param, one to deal with result sets nested in columns, and of course the normal one returned from a call to .executeQuery().
Note that the XML attribute resultMap is already used for result tags, so I called the attribute useResultMapbut perhaps there's a better name that's not too long (e.g. cursorResultMap)?
Thoughts?ClintonOn 2/9/06, Clinton Begin 
[EMAIL PROTECTED] wrote:
Yep. I agree on the need. Just being cautious about the implementation.Cheers,ClintonOn 2/9/06, 
Sven Boden 
[EMAIL PROTECTED] wrote:In case anyone is interested in having a look, I uploaded the patch to
the patch to the wiki,http://opensource2.atlassian.com/confluence/oss/display/IBATIS/Oracle+REF+CURSOR+Solutions
We may need to think some other things over, but a lot of people seem toneed/want something in iBATIS to convert ResultSets from storedprocedures to maps.Sven There can be more than 1 out result sets, Michael's testcases on the
 wiki show that. Will check the second bullet tomorrow, we can probably find a way around it it should also be just a resultset (but I vaguely remember some problems with it from past experiments).
 Sven Clinton Begin wrote: So the assumptions made here are:* There can be only one out parameter of type ResultSet* The default result set (possibly returned from a SELECT) is lost, as
 it's overidden by the ResultSet parameter. Seems a bit hackey, but I'm interested in everyone else's opinion. Clinton On 2/9/06, Sven Boden 
[EMAIL PROTECTED] wrote: I've been playing a bit with Michael Fagan's patch for supporting
 ResultMaps using Oracle ref cursors. Sometimes I'm also a bit fond of
 pushing as much functionality as possible in Oracle procedures and only exposing a ref cursor to the (C) applications. The patch works but having ORACLECURSOR in the iBATIS code puts me a
 bit off. So I made some small cosmetic changes... what about the following: - Michael Fagan's patch (now already to be redone because of other changes in 
2.1.7) - With following changes:# Adding javaType=java.sql.ResultSet to the parameterMapparameterMap id=single-rs class=map 
parameter property=in1 jdbcType=int javaType=java.lang.Integer mode=IN/parameter property=output1 jdbcType=ORACLECURSOR
 javaType=java.sql.ResultSet mode=OUT//parameterMap# doing the ResultSet extraction as follows (hardcoding ResultSet
 instead of ORACLECURSOR).if (mapping.isOutputAllowed()) { if ( java.sql.ResultSet.equalsIgnoreCase(mapping.getJavaTypeName


()) ){ResultSet rs = (ResultSet) cs.getObject( i + 1 );# In the TypeHandlerFactory a shortcut cursor could be made for
 java.sql.ResultSet The above change would not put something Oracle only in iBATIS source code, it would make the SQLMap still dependent on Oracle because of
 ORACLECURSOR but I don't see this as a big problem (as soon as you use SQL dialect in the SqlMaps you're also dependent upon a database). As long as an other database supports a type for cursor it can use
 the implementation above. Or is there something I'm missing, which could come back to haunt us? People using the current patch should then only add
 javaType=java.sql.ResultSet to their maps. Regards, Sven Boden






[jira] Commented: (IBATIS-252) closing resultset cursor in Ibatis

2006-02-09 Thread Sven Boden (JIRA)
[ 
http://issues.apache.org/jira/browse/IBATIS-252?page=comments#action_12365852 ] 

Sven Boden commented on IBATIS-252:
---

If you return ResultSets to your application it's the application's 
responsibility to close them. iBATIS has no way of tracking the state of those 
ResultSets, it would be the same as when done in JDBC. Just close() the  
ResultSet after you've extracted all rows.

Sven

 closing resultset cursor in Ibatis
 --

  Key: IBATIS-252
  URL: http://issues.apache.org/jira/browse/IBATIS-252
  Project: iBatis for Java
 Type: Bug
   Components: SQL Maps
  Environment: ,Ibatis, Java,SQL Server and Oracle 9i
 Reporter: Shiuli Deb


 Issue is Stored Procedures returns an Cursor. Our application which uses 
 Ibatis Java, SQL Server and Oracle 9i, access those Cursors as Resultset. 
 Also our application doesn't use any extra code for getting resultset. So 
 there is something missing somewhere to close the resultset. Please find a 
 way to close the resultsets after getting the values.   

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira