Using 1.0 rc2. Is there a known issue with using custom conversions for primary keys
and is it resolved in a later version?
I've got a table Workspace:
workspace_id int, <- primary key
base_workspace_id int <- recursive foreign key back to the workspace table
with an OJB mapping:
<class-descriptor class="com.whisperwire.services.catalog.repository.Workspace"
table="Workspace">
<field-descriptor name="id" column="workspace_id" jdbc-type="INTEGER"
autoincrement="true"
conversion="com.whisperwire.services.catalog.ojb.WorkspaceOid2Integer"
primarykey="true"/>
<field-descriptor name="baseWorkspaceId" column="base_workspace_id"
jdbc-type="INTEGER"
conversion="com.whisperwire.services.catalog.ojb.WorkspaceOid2Integer" />
<reference-descriptor name="base"
class-ref="com.whisperwire.services.catalog.repository.Workspace">
<foreignkey field-ref="baseWorkspaceId" />
</reference-descriptor>
<collection-descriptor name="childList"
element-class-ref="com.whisperwire.services.catalog.repository.Workspace"
proxy="true">
<inverse-foreignkey field-ref="baseWorkspaceId" />
</collection-descriptor>
</class-descriptor>
mapped to a class
public class Workspace
{
private IOid id;
private IOid baseWorkspaceId;
...
Our oid objects are similar to OJB's Identity object they consist of a combination of
a type and a key, so I've got a custom FieldConversion that's doing the job of
translating back and forth. This all works great on retrieval but I'm getting an
error on insert:
com.inet.tds.SQLException: Not supported type with
setObject:1,com.whisperwire.platform.db.Oid,4
java.sql.SQLException: Not supported type with
setObject:1,com.whisperwire.platform.db.Oid,4
at com.inet.tds.C_PreparedStatement.setObject(C_PreparedStatement.java:625)
at com.inet.tds.C_PreparedStatement.setObject(C_PreparedStatement.java:639)
at
org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectForStatement(Unknown
Source)
at org.apache.ojb.broker.accesslayer.StatementManager.bindInsert(Unknown
Source)
at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown
Source)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.storeToDb(Unknown
Source)
at org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.store(Unknown Source)
>From debugging it looks like
1) the sequence manager correctly generates a new integer value
2) my FieldConversion is called to convert that integer int an oid
3) the oid is set as the key on the new Workspace object
4) the FieldConversion is called to convert the baseWorkspaceId oid back into an
integer when binding to the JDBC insert statement
5) the FieldConversion is **not** called to convert the workspaceId oid back into an
integer when binding to the JDBC insert statement instead it tries to bind the oid
object directly to the JDBC statement resulting in the error
I'm fine with looking into it myself and submitting a patch but before I spend time on
it I want to make sure that it isn't already addressed in a later version.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]