本文介绍了使用hibernate工具从Postgres逆向工程化pojos的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Postgres中创建的数据库中逆向工程化pojos(使用eclipse 3.4.2中的hibernate tools plugin v3.2.4x),但是我的表被忽略。如果我在hibernate.cfg.xml文件中指定'public'作为'hibernate.default_schema'属性的值,但是如果我尝试指定不同的模式,则不会生成任何内容。

I am trying to reverse engineer pojos (using hibernate tools plugin v3.2.4x in eclipse 3.4.2) from a database that I have created in Postgres but my tables are being ignored. It works if I specify 'public' as the value for the 'hibernate.default_schema' property in my hibernate.cfg.xml file but if I try to specify a different schema then nothing is generated.

我已经尝试修改大小写(即较低,上限,骆驼),但我仍然得到相同的结果。这是我的hibernate.cfg.xml文件:

I've tried modifying the case (i.e. lower, upper, camel) but I still get the same result. Here is my hibernate.cfg.xml file:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory name="MyFactory">
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.password">[mypassword]</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/testgis</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.default_schema">locatimus</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    </session-factory>
</hibernate-configuration>

这是pgAdmin III中我的设置​​的图片 -

Here is a picture of my setup in pgAdmin III - http://twitpic.com/snj8i

我很确定我在做(或丢失)一些容易。正如我所说,如果我将模式更改为public,那么该模式中所有表的pojos都将生成!

I'm pretty sure that I'm doing (or missing) something easy. As I say, if I change the schema to public then pojos from all tables in that schema are generated!

任何人都可以帮助?

非常感谢,
Damian

Many thanks,Damian

推荐答案

确定,我发现问题。看来表名必须是小写的,否则hibernate工具看不到它们。我不知道这是否是PostgresSQL方言或Hibernate本身的错误。

OK, I found the problem. It seems that the table names must be in lowercase or hibernate tools does not see them. I don't know if this is a bug with the PostgresSQL dialect or Hibernate itself.

这篇关于使用hibernate工具从Postgres逆向工程化pojos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 12:14