0

I have a one to many mapping with a join table.

class service{private Long service_id}
class codes{private Long code_id}

The service and code classes are setup as hibernate entities and they have mutators for their ids.

The join table

table servicecodes
(serviceid,
codeid);

My service class mapping:

<class name="path.to.Service" table="SERVICE"
lazy="false">

 <set name="sc" table="ServiceCodes">
    <key column="serviceid"/>
    <many-to-many column="codeid" unique="true"
        class="path.to.Codes"/>
 </set>
</class>

In my application layer I have:

serviceobj.set(Set<Codes>);
...
session.save(serviceobj);

At the session.save line, the following error is thrown:

org.hibernate.PropertyAccessException: could not get a field value by reflection    getter of path.to.Codes.code_id
....
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.Long field path.to.Codes.code_id to java.lang.String

1 Answer 1

0

Figured this out myself. The 'codes' class was setup with JPA annotations and the annotations were set on the property declarations. Setting the annotations on the getter methods of the entity's properties solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.