Hello,

Try something like this instead:

   ClassA a = getAnA();
   OQLQuery query = odmg.newOQLQuery();
   query.create("select all from "+
      ClassB.class.getName() +
      " where ClassA.ID = $1"
      );
   query.bind(a.getID());
   query.execute();

Documentation on using the ODMG API can be found at:
   http://db.apache.org/ojb/odmg-tutorial.html

Cheers,
Luis Cruz


On Sat, 2004-03-13 at 04:06, Laurie Harper wrote:
> Hi, I'm using OJB 1.0 RC5 with the ODMG API. Everythings working fine 
> for OQL queries binding basic Java types (like String) but I'm getting 
> an odd error when trying to query foreign key attributes.
> 
> If I do this:
> 
>    ClassA a = getAnA();
>    OQLQuery query = odmg.newOQLQuery();
>    query.create(
>       "select all from "+
>       ClassB.class.getName+
>       " where ClassA = $0"
>    );
> query.bind(a);
> query.execute();
> 
> I get an error that ClassA isn't serializable. If I make it 
> serializable, I get a SQL exception because OJB is passing the 
> serialized form of a as the bound value.
> 
> I'm generating my repository mappings with the xDoclet module and I'm 
> pretty sure they're right (see below). The same code is working fine in 
> another project (though using a much older version of OJB).
> 
> Here's what's in the repository_user.xml for the two classes:
> 
> <class-descriptor
>      class="ClassA"
>      table="ClassA"
>  >
>      <field-descriptor
>          name="ID"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          nullable="false"
>          indexed="true"
>          access="anonymous"
>      />
>      ...
> </class-descriptor>
> 
> <class-descriptor
>      class="ClassB"
>      table="ClassB"
>  >
>      <field-descriptor
>          name="ID"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          nullable="false"
>          indexed="true"
>          access="anonymous"
>      />
>      <field-descriptor
>          name="CLASSA_ID"
>          column="CLASSA_ID"
>          jdbc-type="INTEGER"
>          nullable="false"
>          access="anonymous"
>      />
>      ...
>      <reference-descriptor
>          name="ClassA"
>          class-ref="ClassA"
>      >
>          <foreignkey field-ref="CLASSA_ID"/>
>      </reference-descriptor>
> </class-descriptor>
> 
> The error I get is (once I've made ClassA serializable):
> 
> java.sql.SQLException: Wrong data type: For input string: 
> "aced0005737200276e65742e68...
> 
> I've tried making the primary key column an int property on the class 
> instead of using anonymous access, to no avail. Any idea what I'm doing 
> wrong? (I admit I haven't used OJB in quite a while, so it could 
> something stupid!)
> 
> Thanks,
> 
> L.
> 
> PS, I can post the real repository.xml and all source code if the above 
> is insufficient.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to