cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Savva Kolbachev (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CAY-1985) JDBC Array type is not supported
Date Wed, 18 Mar 2015 13:17:39 GMT

     [ https://issues.apache.org/jira/browse/CAY-1985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Savva Kolbachev updated CAY-1985:
---------------------------------
    Description: 
Summary table of Array type support:

|| || Supported || Links ||
|| db2 || {color:green}true{color} || [DB2 Array type|http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.sqlpl.doc/doc/c0055266.html]
|| derby || {color:red}false{color} || ||
|| firebird || {color:red}false{color} || ||
|| frontbase || {color:red}false{color} || ||
|| h2 || {color:green}true{color} || [H2 Array type|http://www.h2database.com/html/datatypes.html#array_type]
|| hsqldb || {color:green}true{color} || [HSQLDB Array type|http://hsqldb.org/doc/guide/sqlgeneral-chapt.html#sgc_array]
|| ingres || {color:red}false{color} || ||
|| mysql || {color:red}false{color} || ||
|| openbase || {color:red}false{color} || ||
|| oracle || {color:green}true{color} || [Link1|http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm#JJDBC28574]
[Link2|http://docs.oracle.com/cd/B28359_01/appdev.111/b28371/adobjcol.htm#ADOBJ00204]
|| postgres || {color:green}true{color} || [PostgreSQL Array type|http://www.postgresql.org/docs/9.1/static/arrays.html]
|| sqlite || {color:red}false{color} || ||
|| sqlserver || {color:red}false{color} || ||
|| sybase || {color:red}false{color} || ||


At example below I've tried to create -> save -> load object with array field and I
 expect that loaded object will be equal to original.

{code:xml|title=cayenne-project.xml|borderStyle=solid}
<?xml version="1.0" encoding="utf-8"?>
<domain project-version="7">
	<map name="datamap"/>

	<node name="datanode" schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
		<map-ref name="datamap"/>
		<data-source>
			<driver value="org.h2.Driver"/>
			<url value="jdbc:h2:~/test"/>
			<connectionPool min="1" max="1"/>
			<login/>
		</data-source>
	</node>
</domain>
{code}

{code:xml|title=datamap.map.xml|borderStyle=solid}
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
	 project-version="7">
	<property name="defaultPackage" value="com.mycompany.app"/>
	<db-entity name="Object_With_Array">
		<db-attribute name="array" type="ARRAY" length="50"/>
		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
	</db-entity>
	<obj-entity name="ObjectWithArray" className="com.mycompany.app.ObjectWithArray" dbEntityName="Object_With_Array">
		<obj-attribute name="array" type="java.lang.Double[]" db-attribute-path="array"/>
	</obj-entity>
</data-map>
{code}

{code:java|title=App.java|borderStyle=solid}
public class App {
    public static void main( String[] args ) throws ClassNotFoundException, SQLException {
        ServerRuntime runtime = new ServerRuntime("cayenne-project.xml");
        DataContext context = (DataContext)runtime.newContext();

        ObjectWithArray owa = context.newObject(ObjectWithArray.class);
        owa.setArray(new Double[]{1.0, 2.0});
        context.commitChanges();

        List list = context.performQuery(new SelectQuery(ObjectWithArray.class));
        System.out.println(Arrays.toString(((ObjectWithArray) list.get(0)).getArray()));
    }
}

{code}


*Expected result* :  console output [1.0, 2.0]
*Actual result* : exception 
{code}
org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: "(aced0005...00000000000)"
[90004-185]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
	at org.h2.message.DbException.get(DbException.java:179)
	at org.h2.message.DbException.get(DbException.java:155)
	at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:966)
	at org.h2.value.Value.convertTo(Value.java:864)
	at org.h2.value.Value.getBytes(Value.java:411)
	at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1054)
	at org.apache.cayenne.access.types.ByteArrayType.materializeObject(ByteArrayType.java:89)
	at org.apache.cayenne.access.types.ExtendedTypeDecorator.materializeObject(ExtendedTypeDecorator.java:53)
	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:52)
	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:32)
	at org.apache.cayenne.access.jdbc.JDBCResultIterator.nextRow(JDBCResultIterator.java:104)
	at org.apache.cayenne.access.jdbc.JDBCResultIterator.allRows(JDBCResultIterator.java:80)
	at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:181)
	at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
	at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:302)
	at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:439)
	at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:71)
	at org.apache.cayenne.access.DataDomainQueryAction$2.perform(DataDomainQueryAction.java:412)
	at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:53)
	at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:409)
	at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
	at org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:560)
	at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:744)
	at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:552)
	at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:350)
	at org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:106)
	at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:93)
	at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:985)
	at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:974)
{code}



  was:
At example below I've tried to create -> save -> load object with array field and I
 expect that loaded object will be equal to original.

{code:xml|title=cayenne-project.xml|borderStyle=solid}
<?xml version="1.0" encoding="utf-8"?>
<domain project-version="7">
	<map name="datamap"/>

	<node name="datanode" schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
		<map-ref name="datamap"/>
		<data-source>
			<driver value="org.h2.Driver"/>
			<url value="jdbc:h2:~/test"/>
			<connectionPool min="1" max="1"/>
			<login/>
		</data-source>
	</node>
</domain>
{code}

{code:xml|title=datamap.map.xml|borderStyle=solid}
<?xml version="1.0" encoding="utf-8"?>
<data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
	 project-version="7">
	<property name="defaultPackage" value="com.mycompany.app"/>
	<db-entity name="Object_With_Array">
		<db-attribute name="array" type="ARRAY" length="50"/>
		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
	</db-entity>
	<obj-entity name="ObjectWithArray" className="com.mycompany.app.ObjectWithArray" dbEntityName="Object_With_Array">
		<obj-attribute name="array" type="java.lang.Double[]" db-attribute-path="array"/>
	</obj-entity>
</data-map>
{code}

{code:java|title=App.java|borderStyle=solid}
public class App {
    public static void main( String[] args ) throws ClassNotFoundException, SQLException {
        ServerRuntime runtime = new ServerRuntime("cayenne-project.xml");
        DataContext context = (DataContext)runtime.newContext();

        ObjectWithArray owa = context.newObject(ObjectWithArray.class);
        owa.setArray(new Double[]{1.0, 2.0});
        context.commitChanges();

        List list = context.performQuery(new SelectQuery(ObjectWithArray.class));
        System.out.println(Arrays.toString(((ObjectWithArray) list.get(0)).getArray()));
    }
}

{code}


*Expected result* :  console output [1.0, 2.0]
*Actual result* : exception 
{code}
org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: "(aced0005...00000000000)"
[90004-185]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
	at org.h2.message.DbException.get(DbException.java:179)
	at org.h2.message.DbException.get(DbException.java:155)
	at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:966)
	at org.h2.value.Value.convertTo(Value.java:864)
	at org.h2.value.Value.getBytes(Value.java:411)
	at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1054)
	at org.apache.cayenne.access.types.ByteArrayType.materializeObject(ByteArrayType.java:89)
	at org.apache.cayenne.access.types.ExtendedTypeDecorator.materializeObject(ExtendedTypeDecorator.java:53)
	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:52)
	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:32)
	at org.apache.cayenne.access.jdbc.JDBCResultIterator.nextRow(JDBCResultIterator.java:104)
	at org.apache.cayenne.access.jdbc.JDBCResultIterator.allRows(JDBCResultIterator.java:80)
	at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:181)
	at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
	at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:302)
	at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:439)
	at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:71)
	at org.apache.cayenne.access.DataDomainQueryAction$2.perform(DataDomainQueryAction.java:412)
	at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:53)
	at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:409)
	at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
	at org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:560)
	at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:744)
	at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:552)
	at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:350)
	at org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:106)
	at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:93)
	at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:985)
	at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:974)
{code}




> JDBC Array type is not supported
> --------------------------------
>
>                 Key: CAY-1985
>                 URL: https://issues.apache.org/jira/browse/CAY-1985
>             Project: Cayenne
>          Issue Type: Task
>          Components: Core Library
>    Affects Versions: 4.0.M2
>            Reporter: Alex Kolonitsky
>            Assignee: Savva Kolbachev
>
> Summary table of Array type support:
> || || Supported || Links ||
> || db2 || {color:green}true{color} || [DB2 Array type|http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.sqlpl.doc/doc/c0055266.html]
> || derby || {color:red}false{color} || ||
> || firebird || {color:red}false{color} || ||
> || frontbase || {color:red}false{color} || ||
> || h2 || {color:green}true{color} || [H2 Array type|http://www.h2database.com/html/datatypes.html#array_type]
> || hsqldb || {color:green}true{color} || [HSQLDB Array type|http://hsqldb.org/doc/guide/sqlgeneral-chapt.html#sgc_array]
> || ingres || {color:red}false{color} || ||
> || mysql || {color:red}false{color} || ||
> || openbase || {color:red}false{color} || ||
> || oracle || {color:green}true{color} || [Link1|http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraarr.htm#JJDBC28574]
[Link2|http://docs.oracle.com/cd/B28359_01/appdev.111/b28371/adobjcol.htm#ADOBJ00204]
> || postgres || {color:green}true{color} || [PostgreSQL Array type|http://www.postgresql.org/docs/9.1/static/arrays.html]
> || sqlite || {color:red}false{color} || ||
> || sqlserver || {color:red}false{color} || ||
> || sybase || {color:red}false{color} || ||
> At example below I've tried to create -> save -> load object with array field and
I  expect that loaded object will be equal to original.
> {code:xml|title=cayenne-project.xml|borderStyle=solid}
> <?xml version="1.0" encoding="utf-8"?>
> <domain project-version="7">
> 	<map name="datamap"/>
> 	<node name="datanode" schema-update-strategy="org.apache.cayenne.access.dbsync.CreateIfNoSchemaStrategy">
> 		<map-ref name="datamap"/>
> 		<data-source>
> 			<driver value="org.h2.Driver"/>
> 			<url value="jdbc:h2:~/test"/>
> 			<connectionPool min="1" max="1"/>
> 			<login/>
> 		</data-source>
> 	</node>
> </domain>
> {code}
> {code:xml|title=datamap.map.xml|borderStyle=solid}
> <?xml version="1.0" encoding="utf-8"?>
> <data-map xmlns="http://cayenne.apache.org/schema/7/modelMap"
> 	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	 xsi:schemaLocation="http://cayenne.apache.org/schema/7/modelMap http://cayenne.apache.org/schema/7/modelMap.xsd"
> 	 project-version="7">
> 	<property name="defaultPackage" value="com.mycompany.app"/>
> 	<db-entity name="Object_With_Array">
> 		<db-attribute name="array" type="ARRAY" length="50"/>
> 		<db-attribute name="id" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
> 	</db-entity>
> 	<obj-entity name="ObjectWithArray" className="com.mycompany.app.ObjectWithArray"
dbEntityName="Object_With_Array">
> 		<obj-attribute name="array" type="java.lang.Double[]" db-attribute-path="array"/>
> 	</obj-entity>
> </data-map>
> {code}
> {code:java|title=App.java|borderStyle=solid}
> public class App {
>     public static void main( String[] args ) throws ClassNotFoundException, SQLException
{
>         ServerRuntime runtime = new ServerRuntime("cayenne-project.xml");
>         DataContext context = (DataContext)runtime.newContext();
>         ObjectWithArray owa = context.newObject(ObjectWithArray.class);
>         owa.setArray(new Double[]{1.0, 2.0});
>         context.commitChanges();
>         List list = context.performQuery(new SelectQuery(ObjectWithArray.class));
>         System.out.println(Arrays.toString(((ObjectWithArray) list.get(0)).getArray()));
>     }
> }
> {code}
> *Expected result* :  console output [1.0, 2.0]
> *Actual result* : exception 
> {code}
> org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: "(aced0005...00000000000)"
[90004-185]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
> 	at org.h2.message.DbException.get(DbException.java:179)
> 	at org.h2.message.DbException.get(DbException.java:155)
> 	at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:966)
> 	at org.h2.value.Value.convertTo(Value.java:864)
> 	at org.h2.value.Value.getBytes(Value.java:411)
> 	at org.h2.jdbc.JdbcResultSet.getBytes(JdbcResultSet.java:1054)
> 	at org.apache.cayenne.access.types.ByteArrayType.materializeObject(ByteArrayType.java:89)
> 	at org.apache.cayenne.access.types.ExtendedTypeDecorator.materializeObject(ExtendedTypeDecorator.java:53)
> 	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:52)
> 	at org.apache.cayenne.access.jdbc.reader.FullRowReader.readRow(FullRowReader.java:32)
> 	at org.apache.cayenne.access.jdbc.JDBCResultIterator.nextRow(JDBCResultIterator.java:104)
> 	at org.apache.cayenne.access.jdbc.JDBCResultIterator.allRows(JDBCResultIterator.java:80)
> 	at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:181)
> 	at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
> 	at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:302)
> 	at org.apache.cayenne.access.DataDomainQueryAction.runQuery(DataDomainQueryAction.java:439)
> 	at org.apache.cayenne.access.DataDomainQueryAction.access$000(DataDomainQueryAction.java:71)
> 	at org.apache.cayenne.access.DataDomainQueryAction$2.perform(DataDomainQueryAction.java:412)
> 	at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:53)
> 	at org.apache.cayenne.access.DataDomainQueryAction.runQueryInTransaction(DataDomainQueryAction.java:409)
> 	at org.apache.cayenne.access.DataDomainQueryAction.execute(DataDomainQueryAction.java:121)
> 	at org.apache.cayenne.access.DataDomain.onQueryNoFilters(DataDomain.java:560)
> 	at org.apache.cayenne.access.DataDomain$DataDomainQueryFilterChain.onQuery(DataDomain.java:744)
> 	at org.apache.cayenne.access.DataDomain.onQuery(DataDomain.java:552)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:350)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.executePostCache(ObjectContextQueryAction.java:106)
> 	at org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:93)
> 	at org.apache.cayenne.access.DataContext.onQuery(DataContext.java:985)
> 	at org.apache.cayenne.access.DataContext.performQuery(DataContext.java:974)
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message