9 Replies Latest reply on Apr 4, 2007 2:49 AM by Christophe Marcourt

    Upgrade from 1.1.6 to 1.2.1

    Christophe Marcourt Newbie

      Hi all,

      I developped an application under seam 1.1.6. I'm using MySQL 5.
      Everything works fine. Really, seam team keep up the good work !

      I have just an annoying issue.
      I want to upgrade seam 1.1.6 to 1.2.1.
      So I'm creating a new project using seam-gen under seam 1.2.1. I'm copying the java sources from 1.1.6 to 1.2.1 in the src/model and src/action directories within my new project. I'm modifying some xml files: pages.xml, faces-config.xml, application.xml (adding librairies like opncsv.jar, rsslib4j.jar) and that's about it.
      I'm building the project after modifying a little bit the build.xml to integrate the new librairies. Everything is ok.
      As soon as I'm starting jboss my EJBs are deploying but I have problems with SQL data type that I don't had with seam 1.1.6. I'm using TEXT SQL data type in MySQL, I know it's not a good data type but with seam 1.1.6 it worked perfectly. So when deploying I have a Hibernate error which tells me to modify my column data type to VARCHAR(255). I noticed as well that both version of hibernate in seam 1.1.6 and seam 1.2.1 are the same.

      Did I miss something ?

      Thank you.

      Christophe.

        • 1. Re: Upgrade from 1.1.6 to 1.2.1
          Damian Harvey Master

          I have a project under 1.2.1 with a Text datatype that generated fine.

          Try creating a test database and re-generating (ie. using 'vanilla' SeamGen)

          • 2. Re: Upgrade from 1.1.6 to 1.2.1
            Fady Matar Novice

            Can you post the code of the bean that generates this error?

            • 3. Re: Upgrade from 1.1.6 to 1.2.1
              Christophe Marcourt Newbie

               

              "fady.matar" wrote:
              Can you post the code of the bean that generates this error?


              I can but there's nothing to do with the code as it is working perfectly with 1.1.6.
              I think there was a slightly change in a configuration file for hibernate in seam.
              It's the only thing I can see for now.

              • 4. Re: Upgrade from 1.1.6 to 1.2.1
                Christophe Marcourt Newbie

                 

                "damianharvey" wrote:
                I have a project under 1.2.1 with a Text datatype that generated fine.

                Try creating a test database and re-generating (ie. using 'vanilla' SeamGen)


                After creating a new seam-project using seam-gen, I've just created a simple Entity Bean mapping an entity in my MySQL database as is :

                CREATE TABLE `dda`.`e_test` (
                 `test_id` int(10) unsigned NOT NULL auto_increment,
                 `test_name` varchar(45) NOT NULL,
                 `test_text` text,
                 `test_date` timestamp NOT NULL default CURRENT_TIMESTAMP,
                 `test_number` smallint(5) default NULL,
                 PRIMARY KEY (`test_id`)
                );


                the source code of my bean, sorry for the french javadoc ;o)

                package com.cmc.dda.bean;
                
                import java.io.Serializable;
                import java.util.Date;
                
                import javax.persistence.Basic;
                import javax.persistence.Column;
                import javax.persistence.Entity;
                import javax.persistence.GeneratedValue;
                import javax.persistence.Id;
                import javax.persistence.Table;
                import javax.persistence.Temporal;
                import javax.persistence.TemporalType;
                
                import org.hibernate.validator.Length;
                import org.hibernate.validator.NotNull;
                
                /**
                 * La classe Test.
                 */
                @Entity
                @Table(name = "E_TEST")
                public class Test implements Serializable {
                
                 /**
                 * Le date.
                 */
                 private Date date = null;
                
                 /**
                 * Le id.
                 */
                 private int id = -1;
                
                 /**
                 * Le name.
                 */
                 private String name = null;
                
                 /**
                 * Le number.
                 */
                 private int number = -1;
                
                 /**
                 * Le text.
                 */
                 private String text = null;
                
                 /**
                 * Retourne le date.
                 *
                 * @return the date.
                 */
                 @Basic(optional = false)
                 @Temporal(TemporalType.TIMESTAMP)
                 @Column(name = "TEST_DATE", nullable = false)
                 public Date getDate() {
                 return date;
                 }
                
                 /**
                 * Retourne le id.
                 *
                 * @return the id.
                 */
                 @GeneratedValue
                 @Id
                 @Column(name = "TEST_ID", unique = true, nullable = false)
                 public int getId() {
                 return id;
                 }
                
                 /**
                 * Retourne le name.
                 *
                 * @return the name.
                 */
                 @Column(name = "TEST_NAME", nullable = false, length = 45)
                 @NotNull
                 @Length(min = 1, max = 45)
                 public String getName() {
                 return name;
                 }
                
                 /**
                 * Retourne le number.
                 *
                 * @return the number.
                 */
                 @Column(name = "TEST_NUMBER")
                 public int getNumber() {
                 return number;
                 }
                
                 /**
                 * Retourne le text.
                 *
                 * @return the text.
                 */
                 @Column(name = "TEST_TEXT")
                 public String getText() {
                 return text;
                 }
                
                 /**
                 * Positionne le date.
                 *
                 * @param pDate the date to set.
                 */
                 public void setDate(Date pDate) {
                 date = pDate;
                 }
                
                 /**
                 * Positionne le id.
                 *
                 * @param pId the id to set.
                 */
                 public void setId(int pId) {
                 id = pId;
                 }
                
                 /**
                 * Positionne le name.
                 *
                 * @param pName the name to set.
                 */
                 public void setName(String pName) {
                 name = pName;
                 }
                
                 /**
                 * Positionne le number.
                 *
                 * @param pNumber the number to set.
                 */
                 public void setNumber(int pNumber) {
                 number = pNumber;
                 }
                
                 /**
                 * Positionne le text.
                 *
                 * @param pText the text to set.
                 */
                 public void setText(String pText) {
                 text = pText;
                 }
                }


                here is a fragment of the stack trace at the start of jboss :

                15:05:08,578 WARN [ServiceController] Problem starting service persistence.units:ear=deja10ans.ear,
                unitName=deja10ans
                javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: TEST_NUMBER, expected: integer
                 at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
                
                 at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
                 at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)
                ...
                


                I forgot to mention that this code is perfectly working on 1.1.6.

                Cheers.

                Christophe

                • 5. Re: Upgrade from 1.1.6 to 1.2.1
                  Christophe Marcourt Newbie

                  If I modify the datatype of TEST_NUMBER column to integer, I have the next error :

                  15:14:04,062 WARN [ServiceController] Problem starting service persistence.units:ear=deja10ans.ear,
                  unitName=deja10ans
                  javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: TEST_TEXT, expected: varchar(255)
                   at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
                  
                   at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
                   at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:264)


                  And this was working great on 1.1.6, again and again !

                  Christophe

                  • 6. Re: Upgrade from 1.1.6 to 1.2.1
                    Norman Richards Master

                    Are you sure schema validation was enabled before? I can't imagine it was.

                    • 7. Re: Upgrade from 1.1.6 to 1.2.1
                      Christophe Marcourt Newbie

                       

                      "norman.richards@jboss.com" wrote:
                      Are you sure schema validation was enabled before? I can't imagine it was.


                      What do you mean by that ? Do I have to modify something in the configuration files like persistence.xml ?

                      cheers.

                      • 8. Re: Upgrade from 1.1.6 to 1.2.1
                        Christophe Marcourt Newbie

                        Thank you very much Norman,

                        I had indeed in my persistence-dev.xml the following line in 1.1.6 :


                        and in 1.2.1


                        So for the moment I change the value of the "value" attribute to update and it's working. I don't know if it's the good choice but I don't know very well hibernate, I used to develop with OJB. ;o).

                        Thanks again.

                        Christophe.

                        • 9. bad copy/paste
                          Christophe Marcourt Newbie

                          As I had a problem with copy and paste I repost my previous post :

                          Thank you very much Norman,

                          I had indeed in my persistence-dev.xml the following line in 1.1.6 :
                          <property name="hibernate.hbm2ddl.auto" value="update" />

                          and in 1.2.1
                          <property name="hibernate.hbm2ddl.auto" value="validate" />

                          So for the moment I change the value of the "value" attribute to update and it's working. I don't know if it's the good choice but I don't know very well hibernate, I used to develop with OJB. ;o).

                          Thanks again.

                          Christophe.