2 Replies Latest reply on Sep 18, 2009 3:04 AM by harsharuthere

    JPA @Column annotation does not work in JBoss5.x, MySQL [my

      @Column atttributes name and length does not work in JBoss5.x

      here is the code:

      @Entity
      public class ColumnAttribsTesting {
      
       @Id
       @GeneratedValue(strategy=GenerationType.AUTO)
       private Integer id;
      
       private Integer column1 ;
      
       private Integer column2 ;
      
       public ColumnAttribsTesting() {
      
       }
      
       public Integer getId() {
       return id;
       }
      
       public void setId(Integer id) {
       this.id = id;
       }
      
       @Column(name = "abcde", length=1024)
       public Integer getColumn1() {
       return column1;
       }
      
       public void setColumn1(Integer column1) {
       this.column1 = column1;
       }
      
       public Integer getColumn2() {
       return column2;
       }
      
       public void setColumn2(Integer column2) {
       this.column2 = column2;
       }
      
      }
      


      persistence.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <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="atspu" transaction-type="JTA">
      <jta-data-source>java:ats</jta-data-source>
      <class>org.hibernate.ejb.HibernatePersistence</class>
      <properties>
      <property name="hibernate.hbm2ddl.auto" value="update" />
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"></property>
      <property name="hibernate.transaction.manager_lookup_class"
      value="org.hibernate.transaction.JBossTransactionManagerLookup" />
      </properties>
      </persistence-unit>
      </persistence>



      it does not create a column with the name abcde, and the length is always defaults to 255 chars

      i wonder how the basic annotation does not work..
      sure i am doing something silly..


      please help



        • 1. Re: JPA @Column annotation does not work in JBoss5.x, MySQL

          sorry persistence.xml got removed all property tags
          here is the one

          <?xml version="1.0" encoding="UTF-8"?>
          <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="atspu" transaction-type="JTA">
           <jta-data-source>java:ats</jta-data-source>
           <class>org.hibernate.ejb.HibernatePersistence</class>
           <properties>
           <property name="hibernate.hbm2ddl.auto" value="update" />
           <property name="hibernate.show_sql" value="true"/>
           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"></property>
           <property name="hibernate.transaction.manager_lookup_class"
           value="org.hibernate.transaction.JBossTransactionManagerLookup" />
           </properties>
           </persistence-unit>
          </persistence>
          
          


          • 2. Re: JPA @Column annotation does not work in JBoss5.x, MySQL

            hi the issue was resolved. it was my mistake

            1. I used @Coulmn at the getters and @ManyTOOne at the field level.

            2. Also, having a field length of 255 for integer is not correct

            thanks,
            harsha