P
Pavel L.Yatsuk
Hello!
I'm trying to use hibernate for objects wich have relation one to many
all request with selection work fine but with save or update i receive
exception.
Can anybody say whats wrong?
-------------------- exception -------------
27/7/2004 9:44:32 net.sf.hibernate.impl.SessionFactoryObjectFactory
addInstance
INFO: no JNDI name configured
Hibernate: update intcandidate set first_name=?, last_name=?, email=?,
password=? where id=?
27/7/2004 9:44:32 net.sf.hibernate.impl.SessionImpl execute
SEVERE: Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL update or deletion failed (row
not foun
d)
at
net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatche
r.java:25)
at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:672)
at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:625)
at
net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52
)
at
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2262)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at
com.evalica.hudson.candidates.web.CandidateServlet.addemployment(Cand
idateServlet.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
com.evalica.hudson.web.ActionServlet.doGet(ActionServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
My config files and beans
--------- Candidate ----------
<hibernate-mapping>
<class name="com.evalica.hudson.candidates.model.Candidate"
table="intcandidate">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="increment"/>
</id>
<property name="firstName" column="first_name" not-null="true"/>
<property name="lastName" column="last_name" not-null="true"/>
<property name="email" not-null="true"/>
<property name="password" not-null="true"/>
<set name="employments" cascade="all" >
<key column="c_id" />
<one-to-many
class="com.evalica.hudson.candidates.model.Employment"/>
</set>
</class>
</hibernate-mapping>
public class Candidate {
private int id;
private String firstName;
private String lastName;
private String email;
private String password;
private Set employments=new HashSet();
for all present get and set method
-------------- Employment.hbm.xml ------------
<hibernate-mapping>
<class name="com.evalica.hudson.candidates.model.Employment"
table="intemployment">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="increment"/>
</id>
<property name="startDate" column="start_date" type="date"/>
<property name="endDate" column="end_date" type="date"/>
<property name="company" type="string"/>
</class>
</hibernate-mapping>
public class Employment {
private int id;
private Date startDate;
private Date endDate;
private String company;
for all present get and set method
I'm trying to use hibernate for objects wich have relation one to many
all request with selection work fine but with save or update i receive
exception.
Can anybody say whats wrong?
-------------------- exception -------------
27/7/2004 9:44:32 net.sf.hibernate.impl.SessionFactoryObjectFactory
addInstance
INFO: no JNDI name configured
Hibernate: update intcandidate set first_name=?, last_name=?, email=?,
password=? where id=?
27/7/2004 9:44:32 net.sf.hibernate.impl.SessionImpl execute
SEVERE: Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL update or deletion failed (row
not foun
d)
at
net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatche
r.java:25)
at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:672)
at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:625)
at
net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52
)
at
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2262)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at
com.evalica.hudson.candidates.web.CandidateServlet.addemployment(Cand
idateServlet.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
com.evalica.hudson.web.ActionServlet.doGet(ActionServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
My config files and beans
--------- Candidate ----------
<hibernate-mapping>
<class name="com.evalica.hudson.candidates.model.Candidate"
table="intcandidate">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="increment"/>
</id>
<property name="firstName" column="first_name" not-null="true"/>
<property name="lastName" column="last_name" not-null="true"/>
<property name="email" not-null="true"/>
<property name="password" not-null="true"/>
<set name="employments" cascade="all" >
<key column="c_id" />
<one-to-many
class="com.evalica.hudson.candidates.model.Employment"/>
</set>
</class>
</hibernate-mapping>
public class Candidate {
private int id;
private String firstName;
private String lastName;
private String email;
private String password;
private Set employments=new HashSet();
for all present get and set method
-------------- Employment.hbm.xml ------------
<hibernate-mapping>
<class name="com.evalica.hudson.candidates.model.Employment"
table="intemployment">
<id name="id" column="id" type="int" unsaved-value="0" >
<generator class="increment"/>
</id>
<property name="startDate" column="start_date" type="date"/>
<property name="endDate" column="end_date" type="date"/>
<property name="company" type="string"/>
</class>
</hibernate-mapping>
public class Employment {
private int id;
private Date startDate;
private Date endDate;
private String company;
for all present get and set method