9 Replies Latest reply on Feb 6, 2008 3:20 AM by Pericles Junior

    Error Compiling generated entities from Postgre

    Vince Cordaro Newbie

      I have followed the instructions to setup seam by using ./seam setup, inputing all the proper values to connect to my local postgres database. Then I run ./seam create-project and then ./seam generate-entities. All these seem to go through fine.

      My entities get created and it seems to introspect the database with ease, however when I go to run ./seam restart it fails when it tries to compile the generated entities. I get messages about isEmpty in about 5 of my classes.

      All seem to refer to the fact that you cannot have a isEmptry on something that is not a string.

      If I remove these if statements all together then it complains about my database connection. Not sure what is going on here since it connected to the database fine when it generated my entities.

      Do I need to setup a connection pool in JBoss or is that automatically done?

      Thanks in advance..

      Vince

      restart:
      [echo] Restarting project 'adlib_persistence_serivce_generator'

      init:
      [mkdir] Created dir: /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/exploded-archives/adlib_persistence_serivce_generator.jar
      [mkdir] Created dir: /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/exploded-archives/adlib_persistence_serivce_generator.ear
      [mkdir] Created dir: /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/exploded-archives/adlib_persistence_serivce_generator.war
      [mkdir] Created dir: /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/dist

      compile:
      [javac] Compiling 108 source files to /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/exploded-archives/adlib_persistence_serivce_generator.jar
      [javac] /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/src/action/com/echostorm/adlib/advis/persistence/beans/crud/AnnotationVwHome.java:26: isEmpty(java.lang.String) in org.jboss.seam.util.Strings cannot be applied to (java.lang.Integer)
      [javac] if (Strings.isEmpty(getAnnotationVwId().getAnnotationId()))
      [javac] ^
      [javac] /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/src/action/com/echostorm/adlib/advis/persistence/beans/crud/AnnotationVwHome.java:28: isEmpty(java.lang.String) in org.jboss.seam.util.Strings cannot be applied to (java.lang.Integer)
      [javac] if (Strings.isEmpty(getAnnotationVwId().getCaptureId()))
      [javac] ^
      [javac] /Users/vctemp/Development/EchoStorm/workspace/adlib_persistence_serivce_generator/src/action/com/echostorm/adlib/advis/persistence/beans/crud/AnnotationVwHome.java:34: isEmpty(java.lang.String) in org.jboss.seam.util.Strings cannot be applied to (java.io.Serializable)
      [javac] if (Strings.isEmpty(getAnnotationVwId().getAnnotationTextIndex()))

        • 1. Re: Error Compiling generated entities from Postgre
          Pete Muir Master

          I fixed the Strings.isEmpty problem in CVS a while back. Remove the isEmpty's and post your error.

          • 2. Re: Error Compiling generated entities from Postgre
            Vince Cordaro Newbie

            I seemed to have resolved the database connection problem by fixing my jdbc url in seam-gen/build.properties it seems that somehow I got extra backslashes in it.

            However my new error has to do with the definition of a column type.

            12:47:44,370 INFO [SchemaValidator] Running schema validator
            12:47:44,370 INFO [SchemaValidator] fetching database metadata
            12:47:44,410 INFO [TableMetadata] table found: adlib.annotation
            12:47:44,411 INFO [TableMetadata] columns: [capture_id, end_time, at_name, description, content, updated_on, updated_by, start_time, name, a_id]
            12:47:44,424 INFO [TableMetadata] table found: adlib.annotation_tsearch
            12:47:44,424 INFO [TableMetadata] columns: [full_text_index, a_id]
            12:47:44,426 WARN [ServiceController] Problem starting service persistence.units:ear=adlib_persistence_serivce_generator.ear,unitName=adlib_persistence_serivce_generator
            javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: full_text_index, expected: bytea
            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:720)
            at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
            at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)



            Here is the AnnotationTSearch Entity:

            import java.io.Serializable;
            import javax.persistence.Column;
            import javax.persistence.Entity;
            import javax.persistence.FetchType;
            import javax.persistence.Id;
            import javax.persistence.JoinColumn;
            import javax.persistence.ManyToOne;
            import javax.persistence.Table;
            import org.hibernate.validator.NotNull;

            /**
            * AnnotationTsearch generated by hbm2java
            */
            @Entity
            @Table(name = "annotation_tsearch")
            public class AnnotationTsearch implements java.io.Serializable {

            private int AId;
            private Annotation annotation;
            private Serializable fullTextIndex;

            public AnnotationTsearch() {
            }

            public AnnotationTsearch(int AId, Annotation annotation) {
            this.AId = AId;
            this.annotation = annotation;
            }
            public AnnotationTsearch(int AId, Annotation annotation,
            Serializable fullTextIndex) {
            this.AId = AId;
            this.annotation = annotation;
            this.fullTextIndex = fullTextIndex;
            }

            @Id
            @Column(name = "a_id", unique = true, nullable = false)
            @NotNull
            public int getAId() {
            return this.AId;
            }

            public void setAId(int AId) {
            this.AId = AId;
            }
            @ManyToOne(fetch = FetchType.LAZY)
            @JoinColumn(name = "a_id", unique = true, nullable = false, insertable = false, updatable = false)
            @NotNull
            public Annotation getAnnotation() {
            return this.annotation;
            }

            public void setAnnotation(Annotation annotation) {
            this.annotation = annotation;
            }

            @Column(name = "full_text_index")
            public Serializable getFullTextIndex() {
            return this.fullTextIndex;
            }

            public void setFullTextIndex(Serializable fullTextIndex) {
            this.fullTextIndex = fullTextIndex;
            }

            }

            • 3. Re: Error Compiling generated entities from Postgre
              Vince Cordaro Newbie

              The fullTextIndex is a tsvector in the database

              ALTER TABLE adlib.annotation_tsearch DROP COLUMN full_text_index;

              ALTER TABLE adlib.annotation_tsearch ADD COLUMN full_text_index tsvector;
              ALTER TABLE adlib.annotation_tsearch ALTER COLUMN full_text_index SET STORAGE EXTENDED;

              • 4. Re: Error Compiling generated entities from Postgre
                Vince Cordaro Newbie

                Turns out that tsvector is a custom defined postgres datatype. How does seam handle unknown datatypes, like a postgres Geometry Datatype? Can I write a custom handler for these types or do I need to?

                Vince

                Thanks again for the prompt responses...

                • 5. Re: Error Compiling generated entities from Postgre
                  Vince Cordaro Newbie

                  I think I found my own answer. It seems like I maybe able to use
                  seam-gen.reveng.xml file to define that unknown datatype.

                  • 6. Re: Error Compiling generated entities from Postgre
                    Pericles Junior Newbie

                    Hi,

                    How you did that?

                    I have the same problem, I have Framework Seam 2.0.2 but when I use seam-generate-entities it generate *Home.java with this wrong code:

                    @Override
                     public boolean isIdDefined() {
                     if (Strings.isEmpty(getAccionsId().getIdDoc()))
                     return false;
                     if (Strings.isEmpty(getAccionsId().getIdTipus()))
                     return false;
                     if (Strings.isEmpty(getAccionsId().getIdUsuari()))
                     return false;
                     if (Strings.isEmpty(getAccionsId().getData()))
                     return false;
                     return true;
                     }


                    In isEmpty method I have that error:

                    The method isEmpty(String) in the type Strings is not applicable for the arguments (BigDecimal)


                    How can I resolve it?

                    Thanks very much.

                    • 7. Re: Error Compiling generated entities from Postgre
                      Pete Muir Master

                      Err, this was a bug in Seam 2.0.0 so try Seam 2.0.1.GA (Seam 2.0.2 isn't released yet).

                      • 8. Re: Error Compiling generated entities from Postgre
                        Pericles Junior Newbie

                        Oh, sorry, my mistake. I explain me incorrectly.

                        I have Seam 2.0.1.GA, I consult the version just now but the error stils.

                        I'm going to prove it another time, I will create a project step by step.

                        Oh, Note: I use the Seam plug-in if Eclipse. I don't use the MS-DOS entorn.

                        I will post the results of this test.

                        Thanks a lot.

                        • 9. Re: Error Compiling generated entities from Postgre
                          Pericles Junior Newbie

                           

                          "Pericles" wrote:
                          Oh, sorry, my mistake. I explain me incorrectly.

                          I have Seam 2.0.1.GA, I consult the version just now but the error stils.

                          I'm going to prove it another time, I will create a project step by step.

                          Oh, Note: I use the Seam plug-in if Eclipse. I don't use the MS-DOS entorn.

                          I will post the results of this test.

                          Thanks a lot.


                          Great... :P it was my fault. The plug-in don't use internaly Seam 2.0.1 GA. This was the mistake.

                          Thanks.