Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » @Version on @MappedSuperclass
@Version on @MappedSuperclass [message #1778685] Tue, 19 December 2017 23:15 Go to next message
Eclipse UserFriend
Hello

I've a project that run on Payara Application Server, and if I'm not wrong it should use EclipseLink 2.6.

Recently I planned to create a BaseEntity with @MappedSuperclass annotations, so I don't need to declare my @Id and @Version.

@MappedSuperclass
public abstract class BaseEntity implements Serializable, Cloneable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Version
    private Long version;

    /* getter and setter omitted for brevity */


Everything is work well with Derby, but when I started to use MySQL 6 Database I encounter weird situation. I could persist and merge the version variable, but when I tried to retrieve it (of course I query it from the Concrete class and not from the BaseEntity), I always get 0 value.

Could somebody help me with this?
Thank you.
Re: @Version on @MappedSuperclass [message #1779633 is a reply to message #1778685] Wed, 10 January 2018 09:09 Go to previous messageGo to next message
Eclipse UserFriend
This is an old post, but if its still an issue, you would need to look at the SQL statements being generated for the persist/merge and query operations by enabling EclipseLink logging (https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging). If it is working in Derby it should work on MySQL, so hopefully the SQL and the tables themselves might point to the problem.
Re: @Version on @MappedSuperclass [message #1779673 is a reply to message #1779633] Wed, 10 January 2018 23:41 Go to previous message
Eclipse UserFriend
Chris Delahunt wrote on Wed, 10 January 2018 14:09
This is an old post, but if its still an issue, you would need to look at the SQL statements being generated for the persist/merge and query operations by enabling EclipseLink logging (https://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging). If it is working in Derby it should work on MySQL, so hopefully the SQL and the tables themselves might point to the problem.


Hi Chris,

Thanks for the answer, yes I enabled the SQL statements and there is no problem when I do persist or merge. The problem that I face was when I tried to retrieve (select) the data my version field always got 0 (zero).

My current solutions was move the @Version to the child class, but hope to get solutions that won't made me to declare @Version on every entity,

Thank you
Previous Topic:Eclipselink assumes erroneous NoPlatform when target-server not set
Next Topic:update events for @order field
Goto Forum:
  


Current Time: Thu Jul 10 04:16:28 EDT 2025

Powered by FUDForum. Page generated in 0.08777 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top