You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org> on 2005/10/29 04:26:56 UTC
[jira] Created: (IBATIS-210) Enum within Collection is not mapped to custom TypeHandler
Enum within Collection is not mapped to custom TypeHandler
----------------------------------------------------------
Key: IBATIS-210
URL: http://issues.apache.org/jira/browse/IBATIS-210
Project: iBatis for Java
Type: Bug
Components: SQL Maps
Versions: 2.1.0
Environment: Linux/Spring/Resin/Jdk1.5
Reporter: Reuben Firmin
Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
This works, except when the Enum is within a map or a list.
That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped
to custom TypeHandler
Posted by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12363044 ]
Reuben Firmin commented on IBATIS-210:
--------------------------------------
The iterate side of things is a red herring, at least on this bug; if I have the syntax wrong there, sorry.
The real issue is enum support within a collection; if a list or a map contains enums, they aren't properly assigned to their customtypehandlers. I can live with this being a feature request for the time being.
On your final question, I will test and update this bug w/ the results. Please ping me if I haven't by the time you are ready to add support for enums.
Thanks
Reuben
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped
to custom TypeHandler
Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12363039 ]
Clinton Begin commented on IBATIS-210:
--------------------------------------
If it's a list of DeploymentStatus, would you not use: #status[].value# ??
As for enum support, we don't really support JDK 1.5 yet, so we view this is as more of a feature request. Does the same thing happen if DeploymentStatus is a class?
Cheers,
Clinton
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped
to custom TypeHandler
Posted by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12363051 ]
Reuben Firmin commented on IBATIS-210:
--------------------------------------
Hello, an update on this.
#status[].value# does in fact work; however, #status[]# does not. (The first works because the Deployment.Status Enum implements HasValue, which contains a getValue() method.) The second gives this stacktrace:
java.lang.NullPointerException
at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHandler.java:42)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:176)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
at com.ibatis.sqlmap.engine.mapping.statement.CachingStatement.executeQueryForList(CachingStatement.java:100)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
java.lang.NullPointerException
at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHandler.java:42)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:176)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
I also reproduced the bug using a map:
<select id="testCaseForClinton" parameterClass="map" resultClass="long">
SELECT *
FROM Deployment
WHERE statusId=#status#
</select>
public void getIbatisBug210() {
HashMap map = new HashMap();
map.put("status", Deployment.Status.BUILDING);
getSqlMapClientTemplate().queryForObject("Deployment.testCaseForClinton", map);
}
public void testIbatisBug210() throws Exception {
System.out.println("testing ibatis bug 210");
DeploymentDao dao = DeploymentDaoFactory.getDefault();
dao.getIbatisBug210();
fail("it works unexpectedly");
}
With this (the latter being a junit test; the former part of the DeploymentDao), I get the same stacktrace:
java.lang.NullPointerException
at com.ibatis.sqlmap.engine.type.UnknownTypeHandler.setParameter(UnknownTypeHandler.java:42)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameter(BasicParameterMap.java:165)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.setParameters(BasicParameterMap.java:125)
at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:176)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
Again, I know you don't support enums, but wanted to clarify my previous comment.
Thanks
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped to custom TypeHandler
Posted by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12360868 ]
Reuben Firmin commented on IBATIS-210:
--------------------------------------
Hello Clinton -- bug 224 may be related to this (and I posted my type handler code there if you need to refer to it.)
Here is a failing statement:
<select id="getDeploymentByStatus2" parameterClass="list" resultClass="deployment" cacheModel="deployment-cache">
SELECT * FROM Deployment
WHERE deploymentStatusId IN (
<dynamic>
<iterate conjunction=", ">
#status.value[]#
</iterate>
</dynamic>
)
ORDER BY deploymentStatusId, deploymentId
</select>
I traced this up into the ibatis code, and because the Enum (Deployment.Status, which contains a getValue() method) is passed to the statement as part of a list, it doesn't get mapped to my custom TypeHandler (instead it falls back to the UnknownTypeHandler and fails).
To reproduce, essentially:
Declare an Enum;
Create a type handler to convert Enum <-> DB Integer;
Try passing the enum within a map or a list to a statement;
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Updated: (IBATIS-210) Enum within Collection is not mapped
to custom TypeHandler
Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=all ]
Clinton Begin updated IBATIS-210:
---------------------------------
type: New Feature (was: Bug)
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: New Feature
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped
to custom TypeHandler
Posted by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12363036 ]
Reuben Firmin commented on IBATIS-210:
--------------------------------------
Hello, do you need more information on this? I can consistently reproduce it.
Thanks
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped to custom TypeHandler
Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12360720 ]
Clinton Begin commented on IBATIS-210:
--------------------------------------
We'll need a failing test case for this one. I don't understand exactly what it is you're trying to do. Have you tried specifying the Java type exactly?
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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
[jira] Commented: (IBATIS-210) Enum within Collection is not mapped to custom TypeHandler
Posted by "Reuben Firmin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-210?page=comments#action_12356983 ]
Reuben Firmin commented on IBATIS-210:
--------------------------------------
Here is the stacktrace. I have reproduced on 2.1.6
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1768)
at com.ibatis.common.beans.BaseProbe.getIndexedProperty(BaseProbe.java:50)
at com.ibatis.common.beans.GenericProbe.getObject(GenericProbe.java:56)
at com.ibatis.sqlmap.engine.exchange.ListDataExchange.getData(ListDataExchange.java:63)
at com.ibatis.sqlmap.engine.exchange.BaseDataExchange.getCacheKey(BaseDataExchange.java:35)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.getCacheKey(BasicParameterMap.java:136)
at com.ibatis.sqlmap.engine.mapping.statement.BaseStatement.getCacheKey(BaseStatement.java:113)
at com.ibatis.sqlmap.engine.mapping.statement.CachingStatement.getCacheKey(CachingStatement.java:115)
at com.ibatis.sqlmap.engine.mapping.statement.CachingStatement.executeQueryForList(CachingStatement.java:89)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:610)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:584)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:101)
at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForList(SqlMapClientImpl.java:78)
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:245)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:165)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:204)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:243)
> Enum within Collection is not mapped to custom TypeHandler
> ----------------------------------------------------------
>
> Key: IBATIS-210
> URL: http://issues.apache.org/jira/browse/IBATIS-210
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.0
> Environment: Linux/Spring/Resin/Jdk1.5
> Reporter: Reuben Firmin
>
> Passing an Enum to Ibatis requires the declaration of a custom TypeHandler (see my comments here for my implementation: http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How%20do%20I%20use%20a%20Custom%20Type%20Handler%20with%20complex%20property%20or%20Type%20Safe%20Enumeration)
> This works, except when the Enum is within a map or a list.
> That is, if I pass a list of Enum attributes to a statement, as a parameter, and attempt to iterate over them, they are mapped to UnknownTypeHandler. Similarly, when an Enum is passed as value in a HashMap as part of a parameter, it is also mapped to an UnknownTypeHandler.
--
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