Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7073807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:58:26+00:00 2026-05-28T05:58:26+00:00

My client class uses the updateCustomer method in CustomerService class: Customer updatedCustomer = new

  • 0

My client class uses the updateCustomer method in CustomerService class:

    Customer updatedCustomer = new Customer("2314DD0", "POJO World", "Offers POJO service.");
    customerService.updateCustomer(updatedCustomer);

I’ve tried all sorts of things to work around “updateOrSave”, different arguments for update, and so on. The problem that I am encountering according to the stack trace is a (HibernateOptimisticLockingFailureException) and a (org.hibernate.StaleStateException). But let me explain first: All my other data accesses (i.e. save, delete, and query) work perfectly well. I am suspicious about my customer domain class, as well as the Customer.hbm.xml that I’ve set up.

So, my Customer 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 Customer 
{
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 and Setters for ALL instance variables listed after this point. 
}

Finally, my 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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:58:27+00:00Added an answer on May 28, 2026 at 5:58 am

    If it’s a new object, which is implied by new Customer("2314DD0", "POJO World", "Offers POJO service."); then shouldn’t you be calling save() or persist() instead of update()?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class with following description: public class Customer { public ISet<Client> Contacts
class Car extends Viecle Car is compiled. Class Client uses Car . Are fields
I have a class, ClassA that uses a client I wrote to send text
Is it possible in Java to create a static factory method/class that uses an
My application uses the 'twisted.web.client.Agent' to get web content. But the Agent class requires
I have a Client class like that: public class Client { public Person Pers
I am using web client class to HTML data from a web page. Now
I am implementing an asynchronous command pattern for the client class in a client/server
I have a class Client like that: public class Client { public Person Pers
If I have a Client domain class, and that Client hasMany Courses. How do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.