Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I'm a newbie. Not quite sure why the exception is thrown. Please help.
Hibernate version:
3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.is.ems.model.hibernate.Staff" table="staff">
<composite-id name="id" class="com.is.ems.model.hibernate.StaffId">
<key-many-to-one name="Department" class="com.is.ems.model.hibernate.Department">
<column name="departmentId" length="20" not-null="false" />
<column name="companyId" length="11" not-null="false" />
</key-many-to-one>
<key-property name="StaffId" type="java.lang.String">
<column name="staffId" length="10" not-null="true" sql-type="varchar" />
</key-property>
</composite-id>
<property name="Firstname" type="java.lang.String" >
<column name="firstname" length="100" not-null="true" sql-type="varchar" />
</property>
<property name="Lastname" type="java.lang.String">
<column name="lastname" length="100" not-null="true" sql-type="varchar" />
</property>
<property name="Middlename" type="java.lang.String" >
<column name="middlename" length="100" not-null="false" sql-type="varchar" />
</property>
<set name="SetOfSiteemployedstaff" >
<key>
<column name="staffId" length="10" not-null="false" />
<column name="departmentId" length="20" not-null="false" />
<column name="companyId" length="11" not-null="false" />
</key>
<one-to-many class="com.is.ems.model.hibernate.Siteemployedstaff" />
</set>
<set
name="SetOfLogin"
>
<key>
<column name="staffId" length="10" not-null="false" />
<column name="departmentId" length="20" not-null="false" />
<column name="companyId" length="11" not-null="false" />
</key>
<one-to-many
class="com.is.ems.model.hibernate.Login"
/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.is.ems.model.hibernate.Staff#com.is.ems.model.hibernate.StaffId@6ebc254]
org.hibernate.ObjectNotFoundException.throwIfNull(ObjectNotFoundException.java:27)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:171)
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:140)
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:119)
org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:593)
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
com.is.ems.model.hibernate.Staff$$EnhancerByCGLIB$$41392289.getFirstname(<generated>)
com.is.ems.dao.security.login.LoginServiceImpl.authenticate(LoginServiceImpl.java:71)
com.is.ems.web.struts.login.LoginAction.authenticate(LoginAction.java:86)
com.is.ems.web.struts.login.LoginAction.execute(LoginAction.java:69)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Name and version of the database you are using:
MySql 4.1.7
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: