0 Replies Latest reply on Sep 6, 2010 4:09 PM by Christine Chan

    Incorrect insertable=false behaviour?

    Christine Chan Newbie



      I have a problem with envers regarding the insertable property. This problem is being found on the Hibernate 3.5-Release. I'm not sure if this is fixed on a later version, but I have not found a bug for it, so I assume this may still exist.


      Basically envers fails to insert a column when I update a row since the column is marked as insertable=false on a property of a component.


      For example I have a embeddeable object called AuditTrail.


      public class AuditTrail implements Serializable {
          private static final long serialVersionUID = 1L;
          @Column(name="create_timestamp", nullable=false, updatable=false)
          private Date createTimestamp;
          @Column(name="last_update_timestamp", nullable=true, insertable=false)
          private Date lastUpdateTimestamp;
          @Column(name="create_user_code", nullable=false, updatable=false, length=50)
          private String createUserCode;
          @Column(name="last_update_user_code", nullable=true, insertable=false, length=50)
          private String lastUpdateUserCode;


      Audit Trail is embedded in a class called CatalogItem.



      @Table (name="CATALOG_ITEM")
      public class CatalogItem implements Serializable, Translatable {
          @Id @GeneratedValue(strategy=GenerationType.AUTO) @Column(name="id", insertable=false) 
          private Integer id;
          @Column (updatable=false, unique=true, nullable=false, length=10)
          private String code;
          @Column(nullable=false, length=50)
          private String brand;
          private AuditTrail auditTrail = new AuditTrail();


      The sql that gets generated is like this:


              brand = ?
              (REVTYPE, create_timestamp, create_user_code, brand, code, id, REV) 
              (?, ?, ?, ?, ?, ?, ?)


      I'm not sure if this applies to components only either, so this probably should be tested against other cases.


      For now, I have removed all insertable=false annotations from my classes as a temporary fix.


      Before I jump the gun and open a new bug, can someone please confirm this is a valid new bug?