java - Constant error in Hibernate Template update hql -
java - Constant error in Hibernate Template update hql -
my client class uses updatecustomer method in customerservice class:
client updatedcustomer = new customer("2314dd0", "pojo world", "offers pojo service."); customerservice.updatecustomer(updatedcustomer); i've tried sorts of things work around "updateorsave", different arguments update, , on. problem encountering according stack trace (hibernateoptimisticlockingfailureexception) , (org.hibernate.stalestateexception). allow me explain first: other info accesses (i.e. save, delete, , query) work well. suspicious client domain class, customer.hbm.xml i've set up.
so, client service class:
public void updatecustomer(customer updatedcustomer) { this.dao.update(updatedcustomer); } customer service dao:
public void update(customer customertoupdate) { template.update("customer", customertoupdate); } domain.customer class:
public class client { private int id; private string customerid, companyname, email, telephone, notes; private customer() {} public customer(string customerid, string companyname, string email, string telephone, string notes) { this.customerid = customerid; this.companyname = companyname; this.email = email; this.telephone = telephone; this.notes = notes; } //getters , setters instance variables listed after point. } finally, customer.hbm.xml:
<?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd//en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.crm.domain.customer"> <id name="id" column="id"> <generator class="native"/> </id> <property name="customerid"/> <property name="companyname"/> <property name="email"/> <property name="telephone"/> <property name="notes"/> </class>
if it's new object, implied new customer("2314dd0", "pojo world", "offers pojo service."); shouldn't calling save() or persist() instead of update()?
java hibernate spring
Comments
Post a Comment