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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:31:08+00:00 2026-06-15T16:31:08+00:00

I am using EclipseLink as a JPA provider. I am facing issue with version

  • 0

I am using EclipseLink as a JPA provider. I am facing issue with version attribute not being updated whenever a child is added/removed in parent object.

There is a class Company. The Company class has a property Set. The Company class a version field. Whenever I update any non-relationship attribute, the version field of Company instance is increment. However, if I add an instance of Employee class to one-to-many collection employees, version field of Company instance is NOT incremented. Basically, if a child is added to or removed from parent object, version of parent is not incremented.

@Entity
class Company {
   @Id
   private long id;
   private String name;
   @Version
   private Integer version;
   @OneToMany(mappyedBy="company", cascade = CascadeType.ALL, orphanRemoval = true)
   private Set<Employee> employees;
   //
   // setter / getter methods
}

@Entity
class Employee {
   @Id
   private long id;
   private String name;
   @ManyToOne
   @JoinColumn(name = "compid")
   private Company company; 
   //
   // setter / getter methods
}

Hibernate increments version of a parent object if a child is added to or removed from the parent object.

Should not EclipseLink behave the same way? Am I missing something?

Thanks in advance.

  • 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-15T16:31:10+00:00Added an answer on June 15, 2026 at 4:31 pm

    By default EclipseLink increments the lock whenever any direct field, or “owned” relationship changes. I believe this is what the JPA spec dictates. A OneToMany that uses a “mappedBy” is not considered an owned relationship, so does not cause the increment of the version by default.

    You can configure this using, (causes any change to any relationship or dependent object to increment version)

    @OptimisticLocking(cascade=true)
    

    You can also use a DescriptorCustomizer to set, (causes any change to any relationship to increment version)

    descriptor.getOptimisticLockingPolicy().setLockOnChangeMode(LockOnChange.ALL)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing JSF applicationi with JPA using EclipseLink as the persistence provider using
I'm using spring mvc 3.0 with eclipselink and jpa and I'm experiencing following issue:
I have a running web service (using EclipseLink as JPA provider) and would like
I am using EclipseLink as JPA Provider. I want Eclipse Link to Generate my
I'm using EclipseLink as the JPA provider. Further I'm using the following TABLE_PER_CLASS inheritance
I ran into a strange issue while using JPA (with EclipseLink 4.2.1). The relevant
Using Glassfish 3.1 with Eclipselink as JPA provider on board. Got stateless bean with
I have a simple entity. I'm using spring-data-jpa version 1.2.0.RELEASE and eclipselink 2.4.1. @Entity
I am using eclipselink for JPA . I have an entity, which has a
I have entity model like this (using EclipseLink and JPA 2.0): @Entity class A

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.