2 Replies Latest reply on Jul 16, 2006 10:50 AM by Lars Eulberg

    mapping problems between ntext, jtds and ejb3

    Lars Eulberg Newbie

      Hallo,

      I have some tables in an SQL Server DB with ntext fields. I access the db with the jtds 1.2 with the useLOBs=false option. This leads to a mapping of ntext fields to string. Using EJB2 it works fine.

      But now I want to use ejb3 and don't know how to define the mapping annotations. I tried:

       @Column(name="message", columnDefinition="NTEXT NULL")
       public void setMessage(String s){
       this.message = s;
       }
       public String getMessage(){
       return this.message;
       }
      


      But this doesn't work. Hibernate wants to access a varchar(255) field.

      Is anyone out their who knows how to setup?

      Thanks


        • 1. Re: mapping problems between ntext, jtds and ejb3
          Lars Eulberg Newbie

          I tried useLOB=true in jtds and annotation like this

           /**
           * TextArea message
           */
           @Lob @Basic
           @Column(name="message", columnDefinition="NTEXT NULL")
           public void setMessage(String s){
           this.message = s;
           }
           public String getMessage(){
           return this.message;
           }
          


          But no better result.

          In addition the stack trace:

          org.hibernate.HibernateException: Wrong column type: message, expected: varchar(255)
           at org.hibernate.mapping.Table.validateColumns(Table.java:251)
           at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1002)
           at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
           at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
           at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
           at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:627)
          :
          :
          



          • 2. Re: mapping problems between ntext, jtds and ejb3
            Lars Eulberg Newbie

            I solved my problem.

            I annotated the setter and not the getter. Is it neccessary to annotate the getter because of any spec? Which one?

            My code looks like below, now.

             /**
             * TextArea message
             */
             @Lob @Column(columnDefinition="NTEXT NULL")
             public String getMessage(){
             return this.message;
             }
            
             public void setMessage(String s){
             this.message = s;
             }