| Author |
getting error with Hibernate
|
saravana kumar
Ranch Hand
Joined: Jun 25, 2002
Posts: 72
|
|
hi all i am getting error when i run a standalone hibernate program to store a record into a table . i am getting the following error. any one know how to slove this problem ? it would be more helpful for me if any one come up with solution. thanks a lot . the error is ***************Initializing Hibernate Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1.2 Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Environment <clinit> INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=poc, hibernate.connection.pas sword=poc, hibernate.cglib.use_reflection_optimizer=true, hibernate.connection.url=jdbc b2j:C:/Cloudscape/cloudscape;cr eate=true, hibernate.connection.driver_class=com.ibm.db2j.jdbc.DB2jDriver} Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Configuration addClass INFO: Mapping resource: src/hibernateEmp/Emp.hbm.xml Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: src.hibernateEmp.Emp -> EMP Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings WARNING: No dialect set - using GenericDialect: The dialect was not set. Set the property hibernate.dialect. Sep 29, 2004 4:14:39 PM net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use outer join fetching: false Sep 29, 2004 4:14:39 PM net.sf.hibernate.connection.UserSuppliedConnectionProvider configure WARNING: No connection properties specified - the user must supply JDBC connections Sep 29, 2004 4:14:39 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommend ed) Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use scrollable result sets: false Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use JDBC3 getGeneratedKeys(): false Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: false Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: cache provider: net.sf.ehcache.hibernate.Provider Sep 29, 2004 4:14:39 PM net.sf.hibernate.cfg.Configuration configureCaches INFO: instantiating and configuring caches Sep 29, 2004 4:14:39 PM net.sf.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property empid in class src.hibernateEmp.Emp at net.sf.hibernate.property.BasicPropertyAccessor.getSetter(BasicPropertyAccessor.java:131) at net.sf.hibernate.mapping.Property.getSetter(Property.java:182) at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:577) at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:715) at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41) at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:750) at src.hibernateEmp.EmpManager.<init>(EmpManager.java:19) at src.hibernateEmp.EmpManager.main(EmpManager.java:28) Exception in thread "main" java.lang.NullPointerException at src.hibernateEmp.EmpManager.store(EmpManager.java:57) at src.hibernateEmp.EmpManager.main(EmpManager.java:34)
|
 |
Sundar Murthi
Ranch Hand
Joined: Mar 05, 2004
Posts: 209
|
|
hibernate.propery file is missing in ur hibernate program. create the hibernate.property file with proper Dialect and url etc..
|
 |
saravana kumar
Ranch Hand
Joined: Jun 25, 2002
Posts: 72
|
|
Hi Sundar i have created hibernate.propertoes which has the following settings. hibernate.dialect net.sf.hibernate.dialect.DB2Dialect hibernate.connection.driver_class = com.ibm.db2j.jdbc.DB2jDriver hibernate.connection.url = jdbc b2j:C:/Cloudscape/cloudscape;create=true hibernate.connection.username = emp hibernate.connection.password = emp
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
hibernate.propery file is missing in ur hibernate program.
Ehm...it doesn't seem to be - at least the stack trace does log that its loading properties from hibernate.properties. The actual error:
Could not find a setter for property empid in class src.hibernateEmp.Emp
comes when your mapping file defines a property which isn't supported by method in your POJO. In this case it seems Emp doesn't have the appropriate setEmpid([param]) method in it.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
saravana kumar
Ranch Hand
Joined: Jun 25, 2002
Posts: 72
|
|
hi Paul i have proper set method in Emp class. the code is package src.hibernateEmp; public class Emp { private int empid; private String empname; private int deptno; private String deptname; private String designation; public void setEmpId(int empid) { this.empid = empid; } public int getEmpId() { return empid; } public void setEmpName(String name) { empname = name; } public String getEmpName() { return empname; } public void setDeptNo(int dno) { deptno = dno; } public int getDeptNo() { return deptno; } public void setDeptName(String dname) { deptname = dname; } public String getDeptName() { return deptname; } public void setDesignation(String desig) { designation = desig; } public String getDesignation() { return designation; } }
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Hmm. Can you post emp.hbm.xml? [ September 29, 2004: Message edited by: Paul Sturrock ]
|
 |
saravana kumar
Ranch Hand
Joined: Jun 25, 2002
Posts: 72
|
|
hi this is my Emp.hbm.xml file. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="src.hibernateEmp.Emp" table="EMP"> <id name="empid" column="EMPID" type="int"> <generator class="increment"/> </id> <property name="empname" column="NAME"/> <property name="deptno" type="int"/> <property name="deptname" /> <property name="designation" /> </class> </hibernate-mapping>
|
 |
 |
|
|
subject: getting error with Hibernate
|
|
|