Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @Version on @MappedSuperclass
@Version on @MappedSuperclass [message #1778685] Wed, 20 December 2017 04:15 Go to next message
Sukma Wardana is currently offline Sukma WardanaFriend
Messages: 2
Registered: December 2017
Junior Member
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 14:09 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1305
Registered: July 2009
Senior Member
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] Thu, 11 January 2018 04:41 Go to previous message
Sukma Wardana is currently offline Sukma WardanaFriend
Messages: 2
Registered: December 2017
Junior Member
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:MappedSuperClass with EclipseLink
Goto Forum:
  


Current Time: Fri Nov 16 21:02:47 GMT 2018

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

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

Back to the top