These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: a problem with one-to-one relationship
PostPosted: Mon Aug 21, 2006 10:36 pm 
Newbie

Joined: Thu Dec 22, 2005 11:15 pm
Posts: 13
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


Top
 Profile  
 
 Post subject: Getter method should have no parameters
PostPosted: Mon Aug 21, 2006 11:20 pm 
Newbie

Joined: Wed Aug 16, 2006 6:29 pm
Posts: 9
It looks like the getter method has an input parameter. A standard getter method is not expected to have any parameters like this:

Code:
public RouteRes getRouteRes() {
        return this.routeRes;
}


As a result I think Hibernate doesn't recognize the getter and throws the PropertyNotFoundException.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.