2 Replies Latest reply on Oct 15, 2013 9:13 PM by gaoyonglu

    columnDefinition in jboss eap 5.1 does not work

    gaoyonglu

      I have a entity,

      one column:

      @Basic()

        @Column(name="MULTI_REC_IN",columnDefinition="CHAR(1) DEFAULT ' ' ",nullable=false)

        public String getMultiRecIn() {

        return this.multiRecIn;

        }

       

      I think if I not set multiRecIn value ,it will be set " " .,but , I persist ,ERROR say :not-null property references a null or transient value: com.cup.ibsmgm.model.TblParaTblCfg.multiRecIn

       

      so Why not  set the default  " " to the multiRecIn .persistence.xml:

       

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

        version="1.0">

           <persistence-unit name="MGMDB">

        <jta-data-source>jdbc/txmgm</jta-data-source>

      <properties>

        <property name="hibernate.dialect" value="com.cup.dialect.CupDB2Dialect" />

        <property name="hibernate.show_sql" value="true" />

        <property name="hibernate.hbm2ddl.auto" value="none" />

        </properties>

        </persistence-unit>

        • 1. Re: columnDefinition in jboss eap 5.1 does not work
          sfcoy

          I think that error is coming from the JPA implementation before it hits the database. I don't believe that JPA copes with columns other than the primary key being assigned anything other than what is set in your POJO.

          • 2. Re: columnDefinition in jboss eap 5.1 does not work
            gaoyonglu

            I use jboss eap 5.1 and Hibernate Entity Manager is 3.3.2.GA_CP04 Hibernate Entity Manager 3.4.0.GA_CP04 Hibernate Annotations 3.4.0.GA_CP04

             

            My entity is :

            @Entity()

            @Table(name="TBL_MGM_PARA_TBL_CFG")

            public class TblParaTblCfg  implements Serializable, com.cup.common.persistence.PersistenceVO {

              //default serial version id, required for serializable classes.

              private static final long serialVersionUID = 1L;

              private String tblId;

              private String dbTblNm;

              private String entryWizdSeq;

              private String multiRecIn;

              private String parentTblId;

              private String showTblNm;

              private String subjectFldId;

              private String svcGrpId;

              private String tblMaintainTp;

              private String vfyMeansId;

             

             

                public TblParaTblCfg() {

                }

             

             

              @Id()

              @Column(name="TBL_ID", unique=true, nullable=false, length=4)

              public String getTblId() {

              return this.tblId;

              }

              public void setTblId(String tblId) {

              this.tblId = tblId;

              }

             

             

              @Basic()

              @Column(name="DB_TBL_NM", nullable=false, length=128)

              public String getDbTblNm() {

              return this.dbTblNm;

              }

              public void setDbTblNm(String dbTblNm) {

              this.dbTblNm = dbTblNm;

              }

             

             

              @Basic()

              @Column(name="ENTRY_WIZD_SEQ", nullable=false, length=2)

              public String getEntryWizdSeq() {

              return this.entryWizdSeq;

              }

              public void setEntryWizdSeq(String entryWizdSeq) {

              this.entryWizdSeq = entryWizdSeq;

              }

              @Basic()

              @Column(name="MULTI_REC_IN",columnDefinition="CHAR(1) DEFAULT ' ' ",nullable=false)

              public String getMultiRecIn() {

              return this.multiRecIn;

              }

              public void setMultiRecIn(String multiRecIn) {

              this.multiRecIn = multiRecIn;

              }

             

             

              @Basic()

              @Column(name="PARENT_TBL_ID", nullable=false, length=4)

              public String getParentTblId() {

              return this.parentTblId;

              }

              public void setParentTblId(String parentTblId) {

              this.parentTblId = parentTblId;

              }

             

             

              @Basic()

              @Column(name="SHOW_TBL_NM", nullable=false, length=60)

              public String getShowTblNm() {

              return this.showTblNm;

              }

              public void setShowTblNm(String showTblNm) {

              this.showTblNm = showTblNm;

              }

             

             

              @Basic()

              @Column(name="SUBJECT_FLD_ID", nullable=false, length=4)

              public String getSubjectFldId() {

              return this.subjectFldId;

              }

              public void setSubjectFldId(String subjectFldId) {

              this.subjectFldId = subjectFldId;

              }

             

             

              @Basic()

              @Column(name="SYNC_SVC_GRP_ID", nullable=false, length=2)

              public String getSvcGrpId() {

              return this.svcGrpId;

              }

              public void setSvcGrpId(String svcGrpId) {

              this.svcGrpId = svcGrpId;

              }

             

             

              @Basic()

              @Column(name="TBL_MAINTAIN_TP", nullable=false, length=1)

              public String getTblMaintainTp() {

              return this.tblMaintainTp;

              }

              public void setTblMaintainTp(String tblMaintainTp) {

              this.tblMaintainTp = tblMaintainTp;

              }

             

             

              @Basic()

              @Column(name="VFY_MEANS_ID", nullable=false, length=4)

              public String getVfyMeansId() {

              return this.vfyMeansId;

              }

              public void setVfyMeansId(String vfyMeansId) {

              this.vfyMeansId = vfyMeansId;

              }

             

             

              public boolean equals(Object other) {

              if (this == other) {

              return true;

              }

              if (!(other instanceof TblParaTblCfg)) {

              return false;

              }

              TblParaTblCfg castOther = (TblParaTblCfg)other;

              return new EqualsBuilder()

              .append(this.getTblId(), castOther.getTblId())

              .isEquals();

                }

               

              public int hashCode() {

              return new HashCodeBuilder()

              .append(getTblId())

              .toHashCode();

                }  

             

             

              public String toString() {

              return new ToStringBuilder(this)

              .append("tblId", getTblId())

              .toString();

              }

            }