cayenne-commits mailing list archives

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

    [ https://issues.apache.org/jira/browse/CAY-1985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14367159#comment-14367159
] 

John Huss commented on CAY-1985:
--------------------------------

I'd like to have support for this (postgresql).  It would be useful to have more options for
storing denormalized data this way. 

Personally, I'd prefer the java array (or List) to be immutable and force modifications to
go through the setter.

> 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
>
> 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