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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:13:31+00:00 2026-05-24T20:13:31+00:00

I am using hibernate and a version column is provided for the hibernate locking

  • 0

I am using hibernate and a version column is provided for the hibernate locking purposes. The problem is that the app will update an entry often enough that the Java’s int limit is reached by the version column. It is possible that the int limit of the MySQL is also reached.

Is there a way to make the version roll back to zero once it reaches any limit (Java’s or MySQL’s)?

Sure I can just enlarge the data type to be long. But it is just delaying the inevitable.

Edit: I googled around and found this annotation: @OptimisticLock(excluded=true). Link: http://bit.ly/nczCx1 It seems that it can theoretically work but I haven’t successfully use it. Does anyone know how to properly use this annotation?

  • 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-24T20:13:32+00:00Added an answer on May 24, 2026 at 8:13 pm

    @OptimisticLock(excluded=true) works! I just forgot to make sure that I put it on every updated properties. It disallows the version number to be incremented as promised.

    Example:

    @Entity
    @Table(name="some_table")
    public class SomeEntity extends BaseEntity {
        //... some code
    
        @Column
        @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
        @OptimisticLock(excluded=true)
        private DateTime lastUsed = new DateTime();
    
        //... some code
    }
    

    This way, even if the lastUsed properties is updated (and persisted), the version would not increase.

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

Sidebar

Related Questions

I'm using Hibernate for ORM of my Java app to an Oracle database (not
So I'm using hibernate and working with an application that manages time. What is
We are using Hibernate 3.1 with Spring MVC 2.0. Our problem occurs when data
I have a Grails project that is using Hibernate XML. The Hibernate file are
I am building a new web app and I am using Spring, JPA/Hibernate, and
I am new to Hibernate. While creating a small app using it I got
I'm using Hibernate version 3.3.2.GA with annotations. I have inheritance between two classes, the
NHibernate Version: 2.1 I'm using what seems to be a pretty standard HttpModule approach
Using hibernate, how can I persist a class with a List<String> field? Consider the
when using hibernate with spring, can someone explain how the session unit of work

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.