@Version on @MappedSuperclass [message #1778685] |
Tue, 19 December 2017 23:15  |
Eclipse User |
|
|
|
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 #1779673 is a reply to message #1779633] |
Wed, 10 January 2018 23:41  |
Eclipse User |
|
|
|
Chris Delahunt wrote on Wed, 10 January 2018 14:09This 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
|
|
|
Powered by
FUDForum. Page generated in 0.08777 seconds