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