Hi,
I have two objects(TopoLink and RouteRes) with one-to-one relationship as following:
Code:
<class name="com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink" table="TOPO_LINK" schema="IMS123">
<id name="topoLinkCode" type="long">
<column name="TOPO_LINK_CODE" precision="38" scale="0" />
<generator class="seqhilo">
<param name="sequence">SEQ_TOPO_LINK</param>
<param name="max_lo">100</param>
</generator>
</id>
<many-to-one name="subnet" class="com.wish.network_mgr.gdwPersistence.data.mainData.Subnet" fetch="select">
<column name="NET_CODE" precision="10" scale="0" not-null="true" />
</many-to-one>
<one-to-one name="routeRes" class="com.wish.network_mgr.gdwPersistence.data.mainData.RouteRes" cascade="all">
</one-to-one>
Code:
public class TopoLink implements java.io.Serializable {
// Fields
private long topoLinkCode;
private Subnet subnet;
private RouteRes routeRes;
public RouteRes getRouteRes(RouteRes routeRes) {
return this.routeRes;
}
public void setRouteRes(RouteRes routeRes) {
this.routeRes = routeRes;
}
when I create the session factory interperating TopoLink(RouteRes has no problem)it throws the following exception( the information I print before the exception is which I add some log info inside org.hibernate.property.BasicPropertyAccessor.getterMethod()):
Code:
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=topoLinkCode
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=topoLinkCode
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=topoLinkCode
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=subnet
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=subnet
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink, propertyName=routeRes
inside org.hibernate.property.BasicPropertyAccessor.getterMethod(): className=java.io.Serializable, propertyName=routeRes
Initial SessionFactory creation failed.org.hibernate.PropertyNotFoundException: Could not find a getter for routeRes in class com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.wish.network_mgr.gdwPersistence.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at com.wish.network_mgr.gdwPersistence.main.MainProgForGDWPersistence.test(MainProgForGDWPersistence.java:466)
at com.wish.network_mgr.gdwPersistence.main.MainProgForGDWPersistence.main(MainProgForGDWPersistence.java:44)
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for routeRes in class com.wish.network_mgr.gdwPersistence.data.mainData.TopoLink
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:250)
at org.hibernate.tuple.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:255)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:121)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:249)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:411)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:217)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145)
at com.wish.network_mgr.gdwPersistence.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
What is wierd is that during the second call of getterMethod() when process the routeRes property the object calss becomes to java.io.Serializable.
Can anybody tell me what is wrong?
Thanks.
Regards,
Gefei