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 8152639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:46:26+00:00 2026-06-06T15:46:26+00:00

In part of my code, I get an object from database via Hibernate, change

  • 0

In part of my code, I get an object from database via Hibernate, change one field and commit changes back

    session = HibernateUtil.beginTransaction();
    Song song =SongCache.loadSongFromDatabase(session, songId);
    song.setLastModified(new Date(new File(song.getFilename()).lastModified() + 1));
    session.saveOrUpdate(song);
    session.getTransaction().commit();

Song class is defined as , I also use Hibernate Envers and song is audited

/**
 * A Song (or sound recording)
 */
@Audited
@Entity
public class Song
{
    @Id
    @GeneratedValue
    private Integer recNo;

    @Version
    private int version;

    @Basic
    private String filename;

    /**
     * Last Modified Date
     */
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastModified;


    public Song(String file)
    {
        this.setFilename(file);
    }

    public Song()
    {

    }


    @Column(length = 1000)
    private String album;
  ......
}

But sometimes I get a StaleObjectStateException, I cant understand how this can happen

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.jthink.songlayer.Song#1]
    at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2359)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3010)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2908)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3237)
    at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:113)
    at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:272)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:264)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:187)
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1081)
    at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:315)
    at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
    at com.jthink.buzikmusik.analyse.analyser.SongSaver.saveSongToFile(SongSaver.java:286)
    at com.jthink.buzikmusik.analyse.analyser.SongSaver.saveChanges(SongSaver.java:75)
    at com.jthink.buzikmusik.analyse.analyser.SongSaver.call(SongSaver.java:70)
    at com.jthink.buzikmusik.analyse.analyser.SongSaver.call(SongSaver.java:45)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
  • 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-06-06T15:46:27+00:00Added an answer on June 6, 2026 at 3:46 pm

    I do always close the session, but in a finally() block and this can come after I have submitted a task for the same song to another executorservice. So if this task is started before my finally block() in the first task the problem can occur, this was the problem.

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

Sidebar

Related Questions

I'm stuck on one thing i can't get solved. I have part of code,
I have some code that at one part will get executed a lot, and
Part of my code I get the OuterHTML propery <LI onclick=TabClicked(this, 'SearchName', 'TabGroup1');>Name so
20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
I have an application that uses hibernate. At one part I am trying to
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');
I want to test my part of code that returns the users password question.
I am trying to learn and writting this part of code. while testing few
I'm studying data structures (List, Stack, Queue), and this part of code is confusing
Part of my code goes like this: while(1){ my $winmm = new Win32::MediaPlayer; $winmm->load('1.mp3');

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.