【问题标题】:Seam 2.2GA + JBoss AS 5.1GA + Postgres 8.4Seam 2.2GA + JBoss AS 5.1GA + Postgres 8.4
【发布时间】:2009-08-30 17:49:52
【问题描述】:

对不起,文字的大墙,但主要是日志

感谢您对我的任何问题的任何帮助

我一直在尝试从 Seam 论坛获得帮助,但徒劳无功。

我正在尝试标题中提到的这个设置,但没有成功。

我已经正确安装了它,问题从 seam-gen 开始。

这是我的 build.properties

#Generated by seam setup
#Sat Aug 29 19:12:18 BRT 2009
hibernate.connection.password=abc123
workspace.home=/home/rgoytacaz/workspace
hibernate.connection.dataSource_class=org.postgresql.ds.PGConnectionPoolDataSource
model.package=com.atom.Commerce.model
hibernate.default_catalog=PostgreSQL
driver.jar=/home/rgoytacaz/postgresql-8.4-701.jdbc4.jar
action.package=com.atom.Commerce.action
test.package=com.atom.Commerce.test
database.type=postgres
richfaces.skin=glassX
glassfish.domain=domain1
hibernate.default_schema=Core
database.drop=n
project.name=Commerce
hibernate.connection.username=postgres
glassfish.home=C\:/Program Files/glassfish-v2.1
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider
jboss.domain=default
project.type=ear
icefaces.home=
database.exists=y
jboss.home=/srv/jboss-5.1.0.GA
driver.license.jar=
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.url=jdbc\:postgresql\:Atom
icefaces=n

./seam create-project 工作正常,但是当我尝试 generate-entities 时,我得到以下...

generate-model:
     [echo] Reverse engineering database using JDBC driver /home/rgoytacaz/postgresql-8.4-701.jdbc4.jar
     [echo] project=/home/rgoytacaz/workspace/Commerce
     [echo] model=com.atom.Commerce.model
[hibernate] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernate] 1. task: hbm2java (Generates a set of .java files)
[hibernate] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[hibernate] log4j:WARN Please initialize the log4j system properly.
[javaformatter] Java formatting of 4 files completed. Skipped 0 file(s).

这是第一个问题。我该如何解决?这是什么?我不得不在日食中这样做。它奏效了。

然后我将 seam-gen 创建的项目导入 eclipse,并部署到 JBoss 5.1。当我的服务器启动时,我注意到以下内容..

03:18:56,405 ERROR [SchemaUpdate] Unsuccessful: alter table PostgreSQL.atom.productsculturedetail add constraint FKBD5D849BC0A26E19 foreign key (culture_Id) references PostgreSQL.atom.cultures
03:18:56,406 ERROR [SchemaUpdate] ERROR: cross-database references are not implemented: "postgresql.atom.productsculturedetail"
03:18:56,407 ERROR [SchemaUpdate] Unsuccessful: alter table PostgreSQL.atom.productsculturedetail add constraint FKBD5D849BFFFC9417 foreign key (product_Id) references PostgreSQL.atom.products
03:18:56,408 ERROR [SchemaUpdate] ERROR: cross-database references are not implemented: "postgresql.atom.productsculturedetail"*
03:18:56,408 INFO  [SchemaUpdate] schema update complete

问题二。这是什么跨数据库引用?

这个怎么样..

03:18:55,089 INFO  [SettingsFactory] JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.4 JDBC3 (build 701)

问题3 我在build.properties 中说过要使用JDBC4 驱动,不知道为什么seam 坚持使用JDBC3 驱动。我在哪里可以更改?

当我进入 http://localhost:5443/Commerce 并尝试浏览自动生成的 CRUD UI 时。

我收到此错误。在类型 com.atom.Commerce.action.ProductsList_$$_javassist_seam_2 上读取“resultList”时出错

这就是我的服务器日志中显示的内容...

03:34:00,828 INFO  [STDOUT] Hibernate: 
    select
        products0_.product_Id as product1_0_,
        products0_.active as active0_ 
    from
        PostgreSQL.atom.products products0_ limit ?
03:34:00,848 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: 0A000
03:34:00,849 ERROR [JDBCExceptionReporter] ERROR: cross-database references are not implemented: "postgresql.atom.products"
  Position: 81
03:34:00,871 SEVERE [viewhandler] Error Rendering View[/ProductsList.xhtml]
javax.el.ELException: /ProductsList.xhtml: Error reading 'resultList' on type com.atom.Commerce.action.ProductsList_$$_javassist_seam_2
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query

问题 4 这里发生了什么?跨数据库引用?

感谢您对我的任何问题的任何帮助。

【问题讨论】:

    标签: postgresql jakarta-ee jboss seam


    【解决方案1】:

    确实在 Seam 论坛(herehere)上收到了一些答案,但您没有跟进。反正这些其实都是一个问题造成的:

    1. 作为 Stuart Douglas told you,您在连接 PostgreSQL 时不应使用目录。要解决此问题,请将属性文件中的属性“hibernate.default_catalog=PostgreSQL”替换为属性:“hibernate.default_catalog.null=”,以便您的文件如下所示:

      ...
      model.package=com.atom.Commerce.model
      hibernate.default_catalog.null=      # <-- This is the replaced property
      driver.jar=/home/rgoytacaz/postgresql-8.4-701.jdbc4.jar
      ...
      

      之后您应该可以使用seam generate-entities(假设您的其余配置正确)。我建议将生成放入一个干净的文件夹中。

    2. 跨数据库引用是指查询尝试访问两个或多个不同的数据库。 PostgreSQL 不支持这一点,因此当表名中的句点超过 1 个时会报错,因此在 PostgreSQL.atom.productsculturedetail 中,应删除粗体部分。当你告诉 Hibernate 使用默认目录时,它会添加这个前缀,我们已经在上面的步骤 1 中修复了这个问题(通过告诉它不要使用目录),所以这个问题应该在你重新生成实体后修复。

      (请注意,这实际上与 Stuart Douglas 告诉您的相同,您应该删除实体类注释中的 catalog="PostgreSQL" 属性。)

    3. 当您在属性文件中指定postgresql-8.4-701.jdbc4.jar 文件时,这并不意味着驱动程序支持JDBC4。尽管文件名暗示了这一点,但驱动程序的网站clearly states that “驱动程序提供了JDBC 3规范的相当完整的实现”。这对您来说应该不是问题,因为您没有直接使用驱动程序(或者至少您不应该使用)。该驱动程序足以让 Hibernate 满足其要求并提供所需的功能。

    4. 此问题是由上述相同问题引起的。由于查询不正确,Hibernate 无法从数据库中读取数据。修复目录问题应该可以解决这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      相关资源
      最近更新 更多