glassfish
  1. glassfish
  2. GLASSFISH-379

java2db should generate datatypes of Version annotated properties as if they were basic properties

    Details

    • Issuezilla Id:
      379

      Description

      There is nothing in the spec that indicates the @Version annotated properties
      should not behave like regular properties about the choice of the persistence type.

      Hence for the example class (see bellow), the version property that is annotated
      @Version is of type "int" (hence its datawrapper is Integer), so for derby the
      type should be INTEGER !

      But in fact, what is choosen is DECIMAL. See to see a testcase deploy the EAR
      attached to issue 348.

      This means that there is a potential type bounds mismatch between the versions
      that the database can handle and the version the ejb entity and the persistence
      manager can handle. This could result on long term run into unpredictible
      inconsistencies.

      package test;

      import java.math.BigDecimal;
      import javax.persistence.Column;
      import javax.persistence.Entity;
      import java.io.Serializable;
      import javax.persistence.GeneratedValue;
      import javax.persistence.GenerationType;
      import javax.persistence.Id;
      import javax.persistence.TableGenerator;
      import javax.persistence.Version;

      /**
      *

      • @author BJB
        */
        @Entity
        public class TestBigDecimal implements Cloneable, Serializable{

      /**

      • Unique technical identifier
        */
        private long identifier;

      /**

      • technical field for optimistic lock / version of object
        */
        private int version;

      /** Creates a new instance of TestBigDecimal */
      public TestBigDecimal() {
      }

      private BigDecimal amountWithTaxes = BigDecimal.ZERO;

      @Column(nullable=false,precision=10,scale=2)
      public BigDecimal getAmountWithTaxes()

      { return amountWithTaxes; }

      public void setAmountWithTaxes(BigDecimal amountWithTaxes)

      { this.amountWithTaxes = amountWithTaxes; }

      @Id
      @TableGenerator(name = "TEST_SEQUENCE", table = "IDGENERATOR", pkColumnName
      = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "TESTIDENTIFIER",
      initialValue=0, allocationSize=1)
      @GeneratedValue(strategy = GenerationType.TABLE, generator = "TEST_SEQUENCE")
      //@Column(nullable=false, unique=true, updatable=false,insertable=false)
      public long getIdentifier()

      { return identifier; }

      public void setIdentifier(long identifier)

      { this.identifier = identifier; }

      @Version
      public int getVersion()

      { return version; }

      public void setVersion(int version)

      { this.version = version; }

      }

        Activity

        Hide
        marina vatkina added a comment -

        Reassigned

        Show
        marina vatkina added a comment - Reassigned
        Hide
        pramodgo added a comment -

        Have sent code changes for review.

        Show
        pramodgo added a comment - Have sent code changes for review.
        Hide
        pramodgo added a comment -

        Changes have been checked in to rectify this issue.

        Show
        pramodgo added a comment - Changes have been checked in to rectify this issue.

          People

          • Assignee:
            pramodgo
            Reporter:
            bjb
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: