Hi Matt,
Difficult to say for certain from your code snippets but it looks like somewhere you
are trying to set the Customer ID with a String arg when it expects a Long.
IllegalArgumentExceptions during reflection are typically thrown because of a type/arg
mismatch.
Cheers,
Chris
Matt Mastrangelo wrote:
> Hi,
>
> I'm having trouble setting up a 1:1 mapping using OJB 0.9.5. I have two tables:
>"TrackItem" and "Customer". These tables persist two Java classes by the same name.
>Each TrackItem record contains a CustomerID which references a single customer. The
>following are excerpts from my repository-user.xml:
>
> <class-descriptor class="track.TrackItem" table="TRACKITEM">
> <field-descriptor id="1" name="id" column="TI_ID" jdbc-type="BIGINT"
>primarykey="true" autoincrement="true" />
> ....
> (other fields)
> ....
> <field-descriptor id="16" name="customerId" column="TI_CUSTID"
>jdbc-type="BIGINT" />
> <reference-descriptor name="customer" class-ref="track.Customer">
> <foreignkey field-id-ref="16" />
> </reference-descriptor>
> </class-descriptor>
>
> <class-descriptor class="track.Customer" table="CUSTOMER">
> <field-descriptor id="1" name="id" column="CS_ID" jdbc-type="BIGINT"
>primarykey="true" autoincrement="true" />
> ....
> (other fields)
> ....
> </class-descriptor>
>
> Here are excerpts from the corresponding classes:
>
> public class TrackItem implements Serializable {
> private Long id;
> (other attributes)
> private Long customerID;
> private Customer customer;
>
> public TrackItem() { (no args constructor, sets values to null) }
> public TrackItem(.....) { (constructor with args) }
>
> public void setId....
> (other sets)
> public void setCustomerID....
> public void setCustomer....
>
> public Long getId....
> (other gets)
> public Long getCustomerID....
> public Long getCustomer....
> }
> public class Customer implements Serializable {
> private Long id;
> (other attributes)
>
> (constructors...)
>
> (sets & gets)
> }
>
> My application starts up fine with this configuration, however, when I attempt to
>run the following query:
> Criteria crit = new Criteria();
> crit.addEqualTo("logby", "Bob");
> Query query = QueryFactory.newQuery(TrackItem.class, crit);
> coll = broker.getCollectionByQuery(query);
>
> ... I get: org.apache.ojb.broker.PersistenceBrokerException: Unable to build object
>instance :class track.Customer
>
> [DEFAULT] ERROR: Error in operation [set] of object [PersistentFieldPropertyImpl],
>java.lang.IllegalArgumentException
> [DEFAULT] ERROR: Declaring class [track.Customer]
> [DEFAULT] ERROR: Property Name [id]
> [DEFAULT] ERROR: Property Type [java.lang.Long]
> [DEFAULT] ERROR: anObject was class [track.Customer]
> [DEFAULT] ERROR: aValue was class [java.lang.String]
>
> I think there must me something wrong with the way my classes are configured. The
>instructions are not clear to me. Any advice on this problem would be greatly
>appreciated.
>
> Thanks,
>
> Matt
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>