Hello all I am having an on going problem trying to make a relationship which is really one-to-one between two tables. I have read through the hibernate documents and found the many ways to do this in the mapping files, but I cannot get any of them to function all I get in the end is
Full stack trace of any exception that occurs:
Code:
[java] Hibernate: select actiprojec0_.id as id3_, actiprojec0_.name as name
3_, actiprojec0_.name_lower as name3_3_, actiprojec0_.project_code as project4_3
_ from actitime.project actiprojec0_ order by actiprojec0_.id
[java]Exception in thread "main" org.hibernate.PropertyAccessException: ex
ception setting property value with CGLIB (set hibernate.cglib.use_reflection_op
timizer=false for more info) setter of be.eurodyn.costDB.model.ActiProject.setCo
ntID
[java] at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithO
ptimizer(PojoEntityTuplizer.java:215)
[java] at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(Pojo
EntityTuplizer.java:185)
[java] at org.hibernate.persister.entity.AbstractEntityPersister.setPro
pertyValues(AbstractEntityPersister.java:3232)
[java] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLo
ad.java:126)
[java] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(
Loader.java:842)
[java] at org.hibernate.loader.Loader.doQuery(Loader.java:717)
[java] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollec
tions(Loader.java:224)
[java] at org.hibernate.loader.Loader.doList(Loader.java:2150)
[java] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:
2029)
[java] at org.hibernate.loader.Loader.list(Loader.java:2024)
[java] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:36
9)
[java] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslato
rImpl.java:300)
[java] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryP
lan.java:146)
[java] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1093)
[java] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
[java] at be.eurodyn.costDB.test.HibernateTest.main(HibernateTest.java:
143)
[java] Caused by: net.sf.cglib.beans.BulkBeanException: org.hibernate.colle
ction.PersistentSet
[java] at be.eurodyn.costDB.model.ActiProject$$BulkBeanByCGLIB$$63d44e4
3.setPropertyValues(<generated>)
[java] at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithO
ptimizer(PojoEntityTuplizer.java:212)
[java] ... 15 more
[java] Caused by: java.lang.ClassCastException: org.hibernate.collection.Pe
rsistentSet
[java] ... 17 more
[java] Java Result: 1
This seems to be the main error:
Exception in thread "main" org.hibernate.PropertyAccessException: ex
ception setting property value with CGLIB (set hibernate.cglib.use_reflection_op
timizer=false for more info) setter of be.eurodyn.costDB.model.ActiProject.setCo
ntIDMapping documents:This is my mapping for the class creating the relationship:
Code:
<id name="id" column="id">
<generator class="identity" />
</id>
<property name="name" type="string" />
<property name="name_lower" type="string" />
<property name="project_code" type="string" />
<set name="contID" table="cdb_contract" lazy="false" inverse="true">
<key column="id"/>
<one-to-many class="be.eurodyn.costDB.model.Contract"/>
</set>
These are the getters and setters, I have also tried these with Integer and Long as the types as suggested in many forum replies but with no success.
Code:
public int getContID() {
return contID;
}
public void setContID(int contID) {
this.contID = contID;
}
Name and version of the database you are using:
MySql 5
Thanks for taking the time to read I hope someone can shed a little light I am at my wits end. Also how do I turn use_reflection_optimizer to false I cannot find any docs on how to do this?
Cheers
Martin