>
> Sounds great to me.
>
> +1
>
> - Mike
>

Well, got it most of the way done and hitting an obnoxious bug or issue
that I can't pinpoint exactly where it's coming from.  Four of the queries
- two in the ConnectionMapper.xml file and two in the
ConnectionGroupMapper.xml file - are causing some problems.  One example is
below.  Something about the queries where it tries to execute multiple
SELECT statements along with the <foreach> loops - it almost looks like
it's not resetting the start position of the array index in each of the
foreach loops, so when it goes to do the second loop it hits an
ArrayIndexOutOfBoundsException because it's trying to access a parameter
index beyond what's been delivered to it.  It's really, really odd that it
works perfectly fine in PostgreSQL, SQL Server, and MySQL, but fails in
SQLite.  It seems like it should be an issue with MyBatis or MyBatis-Guice,
but the fact that it's only happening in SQLite points to something in the
JDBC driver.

Someone else was, apparently, trying to do this and also ran across the
issue [1].

Anyone have any insight/hints?  I came up with a kludgy way of fixing it -
basically multiple result maps, then splitting out the select statements
into individual statements and calling them from the <collection> tag.
This works fine, but is a bunch of extra XML and doesn't perform nearly as
well since it ends up having to run more queries.

-Nick

[1]
https://stackoverflow.com/questions/41969037/sqlite-mybatis-guice-throw-arrayindexoutofboundsexception

15:22:03.976 [http-nio-8080-exec-997] ERROR o.a.g.rest.RESTExceptionWrapper
- Unexpected internal error:
### Error querying database.  Cause: org.apache.ibatis.type.TypeException:
Could not set parameters for mapping:
ParameterMapping{property='__frch_identifier_2', mode=IN, javaType=class
java.lang.String, jdbcType=VARCHAR, numericScale=null, resultMapId='null',
jdbcTypeName='null', expression='null'}. Cause: org.apac
he.ibatis.type.TypeException: Error setting non null for parameter #3 with
JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a
different configuration property. Cause:
java.lang.ArrayIndexOutOfBoundsException: 2
### The error may exist in
org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT             connection_group_id,
 connection_group_name,             parent_id,             type,
 max_connections,             max_connections_per_user,
 enable_session_affinity         FROM guacamole_connection_group
 WHERE connection_group_id IN
 (                   ?              ,                  ?              ) ;
        SELECT parent_id, connection_group_id         FROM
guacamole_connection_group         WHERE parent_id IN              (
           ?              ,                  ?              ) ;
SELECT parent_id, connection_id
      FROM guacamole_connection         WHERE parent_id IN              (
                 ?              ,                  ?              ) ;
### Cause: org.apache.ibatis.type.TypeException: Could not set parameters
for mapping: ParameterMapping{property='__frch_identifier_2', mode=IN,
javaType=class java.lang.String, jdbcType=VARCHAR, numericScale=null,
resultMapId='null', jdbcTypeName='null', expression='null'}. Cause:
org.apache.ibatis.type.TypeExcepti
on: Error setting non null for parameter #3 with JdbcType VARCHAR . Try
setting a different JdbcType for this parameter or a different
configuration property. Cause: java.lang.ArrayIndexOutOfBoundsException: 2
15:22:04.042 [http-nio-8080-exec-997] DEBUG o.a.g.rest.RESTExceptionWrapper
- Unexpected error in REST endpoint.
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.apache.ibatis.type.TypeException:
Could not set parameters for mapping:
ParameterMapping{property='__frch_identifier_2', mode=IN, javaType=class
java.lang.String, jdbcType=VARCHAR, numericScale=null, resultMapId='null',
jdbcTypeName='null', expression='null'}. Cause: org.apac
he.ibatis.type.TypeException: Error setting non null for parameter #3 with
JdbcType VARCHAR . Try setting a different JdbcType for this parameter or a
different configuration property. Cause:
java.lang.ArrayIndexOutOfBoundsException: 2
### The error may exist in
org/apache/guacamole/auth/jdbc/connectiongroup/ConnectionGroupMapper.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT             connection_group_id,
 connection_group_name,             parent_id,             type,
 max_connections,             max_connections_per_user,
 enable_session_affinity         FROM guacamole_connection_group
 WHERE connection_group_id IN
 (                   ?              ,                  ?              ) ;
        SELECT parent_id, connection_group_id         FROM
guacamole_connection_group         WHERE parent_id IN              (
           ?              ,                  ?              ) ;
SELECT parent_id, connection_id
      FROM guacamole_connection         WHERE parent_id IN              (
                 ?              ,                  ?              ) ;
### Cause: org.apache.ibatis.type.TypeException: Could not set parameters
for mapping: ParameterMapping{property='__frch_identifier_2', mode=IN,
javaType=class java.lang.String, jdbcType=VARCHAR, numericScale=null,
resultMapId='null', jdbcTypeName='null', expression='null'}. Cause:
org.apache.ibatis.type.TypeExcepti
on: Error setting non null for parameter #3 with JdbcType VARCHAR . Try
setting a different JdbcType for this parameter or a different
configuration property. Cause: java.lang.ArrayIndexOutOfBoundsException: 2
        at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
~[na:na]
        at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
~[na:na]
        at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
~[na:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_141]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_141]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_141]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_141]
        at
org.apache.ibatis.session.SqlSessionManager$SqlSessionInterceptor.invoke(SqlSessionManager.java:350)
~[na:na]
        at com.sun.proxy.$Proxy10324.selectList(Unknown Source) ~[na:na]
        at
org.apache.ibatis.session.SqlSessionManager.selectList(SqlSessionManager.java:206)
~[na:na]
        at
org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
~[na:na]
        at
org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
~[na:na]
        at
org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[na:na]
        at com.sun.proxy.$Proxy10381.select(Unknown Source) ~[na:na]
        at
org.apache.guacamole.auth.jdbc.base.ModeledDirectoryObjectService.retrieveObjects(ModeledDirectoryObjectService.java:396)
~[na:na]
        at
org.apache.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirectory.getAll(ConnectionGroupDirectory.java:54)
~[na:na]
        at
org.mybatis.guice.transactional.TransactionalMethodInterceptor.invoke(TransactionalMethodInterceptor.java:96)
~[na:na]
        at
org.apache.guacamole.rest.connectiongroup.ConnectionGroupTree.addConnectionGroupDescendants(ConnectionGroupTree.java:281)
~[classes/:na]
        at
org.apache.guacamole.rest.connectiongroup.ConnectionGroupTree.<init>(ConnectionGroupTree.java:369)
~[classes/:na]
        at
org.apache.guacamole.rest.connectiongroup.ConnectionGroupResource.getConnectionGroupTree(ConnectionGroupResource.java:110)
~[classes/:na]
        at
org.apache.guacamole.rest.RESTExceptionWrapper.invoke(RESTExceptionWrapper.java:153)
~[classes/:na]

Reply via email to