You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Malcolm Edgar <ma...@gmail.com> on 2008/04/17 07:55:11 UTC
Hollow Object issue
Hi Guys,
I have a nasty problem with attempting to perform a refetchObject() on a
hollow object. This is the DataObject toString(), note the primary key
column 'schema_config_oid' has a value of 'B@ceaf8c>'
The primary key column of this database is an BIGINT, this table only has
one record and its PK value is '1'
{<ObjectId:SchemaConfig, schema_config_oid=[B@ceaf8c>; hollow; []}
When I try to refetchObject(), I get a stacktrace of:
Caused by: java.sql.SQLException: Cannot convert class [B to SQL type
requested due to java.lang.ClassCastException - [B
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:2744)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:2532)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setObject(WrappedPreparedStatement.java:420)
at org.apache.cayenne.access.types.AbstractType.setJdbcObject(AbstractType.java:79)
at org.apache.cayenne.access.types.ByteArrayType.setJdbcObject(ByteArrayType.java:191)
at org.apache.cayenne.dba.JdbcAdapter.bindParameter(JdbcAdapter.java:481)
at org.apache.cayenne.access.trans.QueryAssembler.initStatement(QueryAssembler.java:123)
at org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAssembler.java:99)
at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:71)
at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:58)
at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:230)
... 60 more
I presume there is an issue with the PK value bing a hash string value.
Any advice here am I doing something wrong?
regards Malcolm Edgar
Re: Hollow Object issue
Posted by Malcolm Edgar <ma...@gmail.com>.
OK I found my problem it, I had the foreign key in a related DbEntity
defined as a BINARY.
I will close the issue.
regards Malcolm Edgar
On Thu, Apr 17, 2008 at 8:18 PM, Andrus Adamchik <an...@objectstyle.org>
wrote:
>
> On Apr 17, 2008, at 1:13 PM, Malcolm Edgar wrote:
>
> Hi Andrus,
> >
> > the column is a MySQL 5.0 BIGINT, I have tried changing this to an
> > INTEGER
> > and I still had the same problem.
> >
> > regards Malcolm Edgar
> >
>
> So it is BIGINT on MySQL end and in the Cayenne model? Please doublecheck
> that you don't map it as BINARY in the DataMap... Otherwise I can't imagine
> why Cayenne would read it as a byte[].
>
> Andrus
>
Re: Hollow Object issue
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 17, 2008, at 1:13 PM, Malcolm Edgar wrote:
> Hi Andrus,
>
> the column is a MySQL 5.0 BIGINT, I have tried changing this to an
> INTEGER
> and I still had the same problem.
>
> regards Malcolm Edgar
So it is BIGINT on MySQL end and in the Cayenne model? Please
doublecheck that you don't map it as BINARY in the DataMap...
Otherwise I can't imagine why Cayenne would read it as a byte[].
Andrus
Re: Hollow Object issue
Posted by Malcolm Edgar <ma...@gmail.com>.
Hi Andrus,
the column is a MySQL 5.0 BIGINT, I have tried changing this to an INTEGER
and I still had the same problem.
regards Malcolm Edgar
On Thu, Apr 17, 2008 at 8:08 PM, Andrus Adamchik <an...@objectstyle.org>
wrote:
>
> On Apr 17, 2008, at 12:48 PM, Malcolm Edgar wrote:
>
> Caused by: java.sql.SQLException: Cannot convert class [B to SQL type
> > > requested due to java.lang.ClassCastException - [B
> > > at
> > > com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:2744)
> > >
> >
> So I assume that "schema_config_oid" is a PostgreSQL oid column? How is it
> mapped in Cayenne - VARBINARY or something else?
>
> Andrus
>
Re: Hollow Object issue
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 17, 2008, at 12:48 PM, Malcolm Edgar wrote:
>> Caused by: java.sql.SQLException: Cannot convert class [B to SQL
>> type requested due to java.lang.ClassCastException - [B
>> at
>> com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:
>> 2744)
So I assume that "schema_config_oid" is a PostgreSQL oid column? How
is it mapped in Cayenne - VARBINARY or something else?
Andrus
Re: Hollow Object issue
Posted by Malcolm Edgar <ma...@gmail.com>.
Some more analysis on this problem the ObjectId singleValue value is a
byte[] of the table primary key value "3456", and the ObjectId is returning
the raw byte array as the single primary key value.
This is making a mess of Cayenne refreshing objects, lazy loading, etc.
The environment I am using is Cayenne 3.0 M3 on JDK 1.5.0_15
regards Malcolm Edgar
On Thu, Apr 17, 2008 at 3:55 PM, Malcolm Edgar <ma...@gmail.com>
wrote:
> Hi Guys,
>
> I have a nasty problem with attempting to perform a refetchObject() on a
> hollow object. This is the DataObject toString(), note the primary key
> column 'schema_config_oid' has a value of 'B@ceaf8c>'
>
> The primary key column of this database is an BIGINT, this table only has
> one record and its PK value is '1'
>
> {<ObjectId:SchemaConfig, schema_config_oid=[B@ceaf8c>; hollow; []}
>
> When I try to refetchObject(), I get a stacktrace of:
>
> Caused by: java.sql.SQLException: Cannot convert class [B to SQL type requested due to java.lang.ClassCastException - [B
> at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:2744)
>
> at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:2532)
> at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.setObject(WrappedPreparedStatement.java:420)
> at org.apache.cayenne.access.types.AbstractType.setJdbcObject(AbstractType.java:79)
>
> at org.apache.cayenne.access.types.ByteArrayType.setJdbcObject(ByteArrayType.java:191)
> at org.apache.cayenne.dba.JdbcAdapter.bindParameter(JdbcAdapter.java:481)
> at org.apache.cayenne.access.trans.QueryAssembler.initStatement(QueryAssembler.java:123)
>
> at org.apache.cayenne.access.trans.QueryAssembler.createStatement(QueryAssembler.java:99)
> at org.apache.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:71)
> at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:58)
>
> at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:230)
> ... 60 more
>
>
> I presume there is an issue with the PK value bing a hash string value.
>
> Any advice here am I doing something wrong?
>
> regards Malcolm Edgar
>