-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problems finding getters/setters?
PostPosted: Fri Mar 18, 2005 3:13 am 
Newbie

Joined: Thu Dec 23, 2004 7:26 pm
Posts: 11
Hi,

I'm using the MyEclipse tool to generate mapping documents from existing database objects, and ran into a problem. The tool took a column name of "c_LEED_desc" and mapped it to a property of "cLeedDesc". The generated getters and setters were named getCLeedDesc() and setCLeedDesc(), but Hibernate did not recognize them. I found that I could work around it by adding methods getcLeedDesc() and setcLeedDest(), but wondered if anybody else has had this problem.

Shouldn't Hibernate have recognized the getCLeedDesc() and setCLeedDesc() methods?

Hibernate version: 2.1.6

Mapping documents:
...
<property name="cLeedDesc" column="c_LEED_desc" type="java.lang.String" />
...


Code between sessionFactory.openSession() and session.close():


relevent methods:

Code:
    public void setCLeedDesc(java.lang.String cLeedDesc)
    {
        this.cLeedDesc = cLeedDesc;
    }

    public java.lang.String getCLeedDesc()
    {
        return this.cLeedDesc;
    }

/*
    public String getcLeedDesc(){
        return getCLeedDesc();
    }
*/

    public void setcLeedDesc(String cld){
        setCLeedDesc(cld);
    }


Full stack trace of any exception that occurs:

%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.PropertyNotFoundException: Could not find a getter for cLeedDesc in class com.greenbuildingpages.model.Ccerts
at net.sf.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:182)
at net.sf.hibernate.mapping.Property.getGetter(Property.java:175)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:740)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:716)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:136)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:791)
at com.greenbuildingpages.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:53)
at com.greenbuildingpages.dao.CompanyDAO.retrieveCompanyByID(CompanyDAO.java:39)
at com.greenbuildingpages.dao.CompanyDAOTest.testRetrieveCompanyByID(CompanyDAOTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
com.greenbuildingpages.util.GBPException: java.lang.NullPointerException
at com.greenbuildingpages.dao.CompanyDAO.retrieveCompanyByID(CompanyDAO.java:58)
at com.greenbuildingpages.dao.CompanyDAOTest.testRetrieveCompanyByID(CompanyDAOTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.lang.NullPointerException
at com.greenbuildingpages.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:60)
at com.greenbuildingpages.dao.CompanyDAO.retrieveCompanyByID(CompanyDAO.java:39)
... 16 more
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: com/greenbuildingpages/model/Company.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at com.greenbuildingpages.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:52)
at com.greenbuildingpages.dao.CompanyDAO.retrieveCompanyByID(CompanyDAO.java:39)
at com.greenbuildingpages.dao.CompanyDAOTest.testSaveToReviewTables(CompanyDAOTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: duplicate import: Company
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 21 more
failed here.
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: com/greenbuildingpages/model/Company.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at com.greenbuildingpages.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:52)
at com.greenbuildingpages.dao.CompanyDAO.retrieveAllCompanies(CompanyDAO.java:143)
at com.greenbuildingpages.dao.CompanyDAOTest.testRetrieveAllCompanies(CompanyDAOTest.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: net.sf.hibernate.MappingException: duplicate import: Company
at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 21 more


Name and version of the database you are using: MySQL 4.1


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 9:19 am 
Newbie

Joined: Thu Mar 17, 2005 8:44 pm
Posts: 6
Look like either your project containing mapping files is not in reference or in classpath with with your tool's project.
Try doing like that ..and take care of one more thing..
either give your tool ..path of hibernate config file or mapping files individually..dont give them both..Generally these tools have various options like ...

- properties files
- config files
- mapping files..

Just choose one of both..


Top
 Profile  
 
 Post subject: Clarification
PostPosted: Fri Mar 18, 2005 11:52 am 
Newbie

Joined: Thu Dec 23, 2004 7:26 pm
Posts: 11
I don't think that's the problem. I should have clarified; when the getter getcLeedDesc() is not commented out, everything works fine. Note that getcLeedDesc() is not the correct name of the getter for the cLeedDesc property (as I understand it). There already exists a getCLeedDesc() getter that is not commented out, but Hibernate does not associate that method name with the cLeedDesc property.

I'm pretty sure I've ruled out all environmental issues; the code does work, but only when I add a getter and setter where the first character of the property name is lower case rather than upper case. I will note that this is the ONLY property (out of over 150 in about 10 mapping files) where I have had this problem.

Thanks!

Todd


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.