Hello, I just wanted to introduce a superclass for all entities in my app. The goal was to define several common behaviour like creation and modification dates. The problem is that if I define a field timestampModification annotated with @Version in the superclass annotated with @MappedSuperclass, it doesn't seem to be inherited by the subclassing entities (it is ignored and its value is still null even after inserting or updating the entity). If I define the attribute annotated with @Version in the subclass, it works. I think there's something wrong but what ? Thank you for your answer.
Here is the code : ________________________________________________________ package fr.cpage.fmk.core.business.entity.impl; import java.sql.Timestamp; import javax.persistence.Column; import javax.persistence.MappedSuperclass; import javax.persistence.Version; import fr.cpage.fmk.core.business.entity.CPageObject; @MappedSuperclass public class CPageEntity { private String utilisateurCreation; private String utilisateurModification; @Column(columnDefinition = "TIMESTAMP") private Timestamp timestampCreation; @Column(columnDefinition = "TIMESTAMP") @Version protected Timestamp timestampModification; public String getUtilisateurCreation() { return this.utilisateurCreation; } public String getUtilisateurModification() { return this.utilisateurModification; } public void setUtilisateurCreation(String utilisateurCreation) { this.utilisateurCreation = utilisateurCreation; } public void setUtilisateurModification(String utilisateurModification) { this.utilisateurModification = utilisateurModification; } public Timestamp getTimestampCreation() { return this.timestampCreation; } public Timestamp getTimestampModification() { return this.timestampModification; } public void setTimestampCreation(Timestamp timestampCreation) { this.timestampCreation = timestampCreation; } public void setTimestampModification(Timestamp timestampModification) { this.timestampModification = timestampModification; } } ________________________________________________________ package fr.cpage.fmk.demo1.business.entity.impl; import java.io.Serializable; import java.sql.Timestamp; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import fr.cpage.fmk.core.business.entity.impl.CPageEntity; import fr.cpage.fmk.demo1.business.entity.Visitor; @Entity public class VisitorEntity extends CPageEntity { /** * Le constructeur par défaut. * */ protected VisitorEntity() { // protected contructor } /** * @param name le nom du visiteur */ public VisitorEntity(String name) { this.name = name; } @Id @GeneratedValue private Long id; private String name; public Long getId() { return this.id; } public void setId(Long poId) { this.id = poId; } public String getName() { return this.name; } public void setName(String poName) { this.name = poName; } @Override public String toString() { return super.toString() + "[" + this.getName() + " ; " + this.getTimestampModification() + "]"; } } View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3950637#3950637 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3950637 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user