• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

getting error with Hibernate

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hibernate.propery file is missing in ur hibernate program.
create the hibernate.property file with proper Dialect and url etc..
 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. Can you post emp.hbm.xml?
[ September 29, 2004: Message edited by: Paul Sturrock ]
 
saravana kumar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Can't .... do .... plaid .... So I did this tiny ad instead:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic