[jboss-user] [JBoss Seam] - seam-gen 'generate-entities' generates invalid code for tabl

voreichel do-not-reply at jboss.com
Wed Nov 14 12:43:16 EST 2007


Using seam-gen 'generate-entities' to generate a CRUD application from an existing PostgreSQL database does not generate working code.

I have the follwing two tables in my database:
Table t_user

  | CREATE TABLE t_user
  | (
  |   email character varying(255) NOT NULL,
  |   firstname character varying(255),
  |   lastname character varying(255),
  |   loginname character varying(255),
  |   "password" character varying(255),
  |   joined timestamp without time zone,
  |   CONSTRAINT t_user_pkey PRIMARY KEY (email)
  | ) 
  | 
and a second table t_user_roles

  | CREATE TABLE t_user_roles
  | (
  |   t_user_email character varying(255) NOT NULL,
  |   element integer,
  |   CONSTRAINT fk8fc22a14c7001400 FOREIGN KEY (t_user_email)
  |       REFERENCES t_user (email) MATCH SIMPLE
  |       ON UPDATE NO ACTION ON DELETE NO ACTION
  | ) 
  | 

element encodes which role a user is in.

When I run seam generate-entities I get no errors or warnings

  | C:\seam-buch\seam\jboss-seam-2.0.0.GA>seam generate-entities
  | C:\seam-buch\jdk\jdk_1_5_0_12
  | Buildfile: C:\seam-buch\seam\jboss-seam-2.0.0.GA\seam-gen\build.xml
  | 
  | init:
  | 
  | init-properties:
  |      [echo] c:/seam-buch/appserv/jboss-4.2.1.GA
  | 
  | validate-workspace:
  | 
  | validate-project:
  | 
  | generate-entities:
  |      [echo] Reverse engineering database using JDBC driver C:/seam-buch/appserv/jboss-4.2.1.GA/server\default/lib/postgresql-8.2-506.jdbc2ee.jar
  |      [echo] project=c:/seam-buch/workspaceJBossTools/seamquizadmin
  |      [echo] model=com.seamguru.seamquizadmin
  | [hibernate] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
  | [hibernate] 1. task: hbm2java (Generates a set of .java files)
  | [hibernate] 14.11.2007 17:53:12 org.hibernate.cfg.Environment <clinit>
  | [hibernate] INFO: Hibernate 3.2.5
  | [hibernate] 14.11.2007 17:53:12 org.hibernate.cfg.Environment <clinit>
  | [hibernate] INFO: hibernate.properties not found
  | [hibernate] 14.11.2007 17:53:12 org.hibernate.cfg.Environment buildBytecodeProvider
  | [hibernate] INFO: Bytecode provider name : cglib
  | [hibernate] 14.11.2007 17:53:12 org.hibernate.cfg.Environment <clinit>
  | [hibernate] INFO: using JDK 1.4 java.sql.Timestamp handling
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.reveng.OverrideRepository addFile
  | [hibernate] INFO: Override file: c:\seam-buch\workspaceJBossTools\seamquizadmin\resources\seam-gen.reveng.xml
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider configure
  | [hibernate] INFO: Using Hibernate built-in connection pool (not for production use!)
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider configure
  | [hibernate] INFO: Hibernate connection pool size: 20
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider configure
  | [hibernate] INFO: autocommit mode: false
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider configure
  | [hibernate] INFO: using driver: org.postgresql.Driver at URL: jdbc:postgresql:seamDB
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider configure
  | [hibernate] INFO: connection properties: {user=postgres, password=****}
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: RDBMS: PostgreSQL, version: 8.2.5
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC2 with NO SSL (build 506)
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.dialect.Dialect <init>
  | [hibernate] INFO: Using dialect: org.hibernate.dialect.PostgreSQLDialect
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
  | [hibernate] INFO: Using default transaction strategy (direct JDBC transactions)
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
  | [hibernate] INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Automatic flush during beforeCompletion(): disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Automatic session close at end of transaction: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: JDBC batch size: 15
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: JDBC batch updates for versioned data: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Scrollable result sets: enabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: JDBC3 getGeneratedKeys(): disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Connection release mode: auto
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Default batch fetch size: 1
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Generate SQL with comments: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Order SQL updates by primary key: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Order SQL inserts for batching: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
  | [hibernate] INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
  | [hibernate] INFO: Using ASTQueryTranslatorFactory
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Query language substitutions: {}
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: JPA-QL strict compliance: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Second-level cache: enabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Query cache: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory createCacheProvider
  | [hibernate] INFO: Cache provider: org.hibernate.cache.HashtableCacheProvider
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Optimize cache for minimal puts: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Structured second-level cache entries: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Statistics: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Deleted entity synthetic identifier rollback: disabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Default entity-mode: pojo
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.cfg.SettingsFactory buildSettings
  | [hibernate] INFO: Named query checking : enabled
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider close
  | [hibernate] INFO: cleaning up connection pool: jdbc:postgresql:seamDB
  | [hibernate] 14.11.2007 17:53:13 org.hibernate.tool.Version <clinit>
  | [hibernate] INFO: Hibernate Tools 3.2.0.b10
  | 14.11.2007 17:53:13 org.hibernate.connection.DriverManagerConnectionProvider close
  | INFO: cleaning up connection pool: jdbc:postgresql:seamDB
  | [hibernate] 2. task: generic exportertemplate: view/list.xhtml.ftl
  | [hibernate] 3. task: generic exportertemplate: view/view.xhtml.ftl
  | [hibernate] 4. task: generic exportertemplate: view/view.page.xml.ftl
  | [hibernate] 5. task: generic exportertemplate: view/edit.xhtml.ftl
  | [hibernate] 6. task: generic exportertemplate: view/edit.page.xml.ftl
  | [hibernate] 7. task: generic exportertemplate: src/EntityList.java.ftl
  | [hibernate] 8. task: generic exportertemplate: view/list.page.xml.ftl
  | [hibernate] 9. task: generic exportertemplate: src/EntityHome.java.ftl
  | [hibernate] 10. task: generic exportertemplate: view/layout/menu.xhtml.ftl
  | [javaformatter] Java formatting of 14 files completed. Skipped 0 file(s).
  |      [echo] Type 'seam restart' and go to http://localhost:8080/seamquizadmin
  | 
  | BUILD SUCCESSFUL
  | Total time: 3 seconds
  | 
  | C:\seam-buch\seam\jboss-seam-2.0.0.GA>
  | 

Running seam restart terminates without warning or error:


  | C:\seam-buch\seam\jboss-seam-2.0.0.GA>seam restart
  | C:\seam-buch\jdk\jdk_1_5_0_12
  | Buildfile: C:\seam-buch\seam\jboss-seam-2.0.0.GA\seam-gen\build.xml
  | 
  | init:
  | 
  | init-properties:
  |      [echo] c:/seam-buch/appserv/jboss-4.2.1.GA
  | 
  | validate-workspace:
  | 
  | validate-project:
  | 
  | restart:
  |      [echo] Restarting project 'seamquizadmin'
  | 
  | init:
  | 
  | compile:
  |     [javac] Compiling 14 source files to c:\seam-buch\workspaceJBossTools\seamquizadmin\exploded-archives\seamquizadmin.jar
  | 
  | copyclasses:
  | 
  | jar:
  |      [copy] Copying 1 file to c:\seam-buch\workspaceJBossTools\seamquizadmin\exploded-archives\seamquizadmin.jar\META-INF
  |      [copy] Copying 1 file to c:\seam-buch\workspaceJBossTools\seamquizadmin\exploded-archives\seamquizadmin.jar
  | 
  | war:
  |      [copy] Copying 25 files to c:\seam-buch\workspaceJBossTools\seamquizadmin\exploded-archives\seamquizadmin.war
  | 
  | ear:
  | 
  | datasource:
  | 
  | explode:
  |      [copy] Copying 16 files to c:\seam-buch\appserv\jboss-4.2.1.GA\server\default\deploy\seamquizadmin.ear\seamquizadmin.jar
  |      [copy] Copying 25 files to c:\seam-buch\appserv\jboss-4.2.1.GA\server\default\deploy\seamquizadmin.ear\seamquizadmin.war
  | 
  | restart:
  | 
  | BUILD SUCCESSFUL
  | Total time: 2 seconds
  | 
  | C:\seam-buch\seam\jboss-seam-2.0.0.GA>
  | 

Then I tried to open the generated webapp in a browser:
[img]http://www.seamguru.com/jbossforum/img/seamgenDBbug.jpg[/img]
[urlhttp://www.seamguru.com/jbossforum/img/seamgenDBbug.jpg[/url]

The error message tells me that class 'com.seamguru.seamquizadmin.TUserList' does not have a property 'tUser'.

The generated class TUserList defines a member tUser and a getter (getTUser). When I change the getter to gettUser. Please note the lowercase 't' in TUser. I get one step further.
Now I get a similar error for class TUserRoleList. Making similar change fixes this problem too.

Now the home screen of the application is rendered correctly. But selecting 'TUserRolesList' from the menu on the top of the page gives a similar error message as the the two before. Now property 'tUserEmail' cannot be found.

See [img]http://www.seamguru.com/jbossforum/img/seamDBBug2.png[/img]

See http://www.seamguru.com/jbossforum/img/seamDBBug2.png

My questions are:

Has anyone else seen this error?

Why does the error message complain about 'tUserEmail' / 'tUser' as far as I can see 'tUser' / 'tUserEmail' is not used in the XHTML pages?

Any response welcome!

Volker



 
Environment Information:

  | Seam 2.0.0.GA
  | PostgreSQL 8.2
  | JBoss 4.2.1.GA
  | Windows XP
  | Java 1.5
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104710#4104710

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104710



More information about the jboss-user mailing list