7 Replies Latest reply on Jun 13, 2008 8:42 PM by Cloves Almeida

    CRUD oddites

    JR Wilbert Newbie

      Forgive me if this is an known issue but  I am new to Seam.

      I am working on porting a PHP web site over to seam and it seams the seam generate incorrect code for the entity.

      It seams that it treats tinyint as boolean in the model but as int in the action code.

      Is there a better way than converting all tinyint into something else?

        • 1. Re: CRUD oddites
          Cloves Almeida Newbie

          Please post your persistence.xml file and some code.

          • 2. Re: CRUD oddites
            JR Wilbert Newbie

            This is the only table in the database ( MySQL 5.0 )

            CREATE TABLE IF NOT EXISTS Group (
              GroupID int(16) NOT NULL auto_increment,
              Name varchar(48) NOT NULL default '',
              Paging char(1) NOT NULL default '',
              VLAN varchar(4) NOT NULL default '',
              Address1 varchar(64) NOT NULL default '',
              Address2 varchar(64) NOT NULL default '',
              City varchar(48) NOT NULL default '',
              State char(2) NOT NULL default '',
              Zip varchar(12) NOT NULL default '',
              ContractStartDate datetime NOT NULL default '0000-00-00 00:00:00',
              LocationCode varchar(12) NOT NULL default '',
              EMLogoutTime mediumint(8) unsigned NOT NULL default '1200',
              Active tinyint(1) NOT NULL default '1',
              UNIQUE KEY GroupID (GroupID)
            ) ENGINE=MyISAM

            then execute 

            seam create-project
            seam generate-entities 
            seam deploy

            the build dies with

            [javac] Compiling 3 source files to
            [javac] c:\Users\jr\workspace\PrismOnePortal\src\action\com\prismone\portal\GroupHome.java:25: incomparable types: boolean and int
            [javac]             if (getGroupId().isActive() == 0)
            [javac] 1 error

            here is the persistence.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <!-- Persistence deployment descriptor for prod profile -->
            <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
               <persistence-unit name="PrismOnePortal">
                     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
                     <property name="hibernate.hbm2ddl.auto" value="validate"/>
                     <property name="hibernate.jdbc.batch_size" value="20"/>
                     <property name="jboss.entity.manager.factory.jndi.name" value="java:/PrismOnePortalEntityManagerFactory"/>

            • 3. Re: CRUD oddites
              JR Wilbert Newbie

              I am using jboss-seam-2.0.2.SP1

              • 4. Re: CRUD oddites
                Cloves Almeida Newbie

                1) Try using bit(1) datatype instead of tinyint(1)
                2) Try using newer versions of connector/j. The version I find most stable is the 5.0.8. Currently I use a patched 5.1.6

                BTW, I strongly advise you switching to the InnoDB engine. MyISAM, despite being fast, has no transaction or FK support. And Seam/CMP is all about transaction.

                • 5. Re: CRUD oddites
                  JR Wilbert Newbie

                  Click HELP for text formatting instructions. Then edit this text and check the preview.
                  Thanks for the advice.

                  Re: Using bit :  I started to, but I wanted to see if there where other ways around it.

                  Re: InnoDB :  Do you know of anything that is lost from Seam/CMP with using MyISAM? Or any links you can point me to ?

                  Beyond googling seam myisam  ?

                  • 6. Re: CRUD oddites
                    JR Wilbert Newbie

                    Click HELP for text formatting instructions. Then edit this text and check the preview.
                    Sorry the big thing was missed

                    Thank for the info.

                    • 7. Re: CRUD oddites
                      Cloves Almeida Newbie

                      By using MyISAM, you simply lose the ability to use transactions.

                      One of the issues is that you cannot use long running conversations. Also, if you run into an exception while populating your bean, seam by default rollback the transaction - with MyISAM you need to manually do this.

                      In fact, Seam depends so much on transactions that you'll probably run into some very nasty bugs if you use MyISAM. Be free to do futher research, but I'd not even try.