读取模式时出现Hibernate配置错误

时间:2015-05-18 10:02:25

标签: java hibernate postgresql jboss jboss-tools

嘿stackoverflow

我尝试将Hibernate配置添加到我的工作区,以便对我的数据库进行反向工程。 当我在“休眠配置”视图中打开数据库点时,我得到一个Reading schema error: null,但有以下异常:

java.lang.NullPointerException
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter$1.compare(LazyDatabaseSchemaWorkbenchAdapter.java:76)
at java.util.TimSort.countRunAndMakeAscending(Unknown Source)
at java.util.TimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.toArray(BasicWorkbenchAdapter.java:75)
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.getChildren(LazyDatabaseSchemaWorkbenchAdapter.java:74)
at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:104)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

以前有人经历过这个吗? 我正在运行全新安装的Eclipse Luna / Newest JBoss Tools并尝试连接到PostgreSQL 9.3 DB。

提前谢谢

修改

我的hibernate.cfg.xml

<?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>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.password">******</property>
        <property name="hibernate.connection.url">jdbc:postgresql://10.244.7.77:5432/netview</property>
        <property name="hibernate.connection.username">admin</property>
        <property name="hibernate.default_schema">public</property>
    </session-factory>
</hibernate-configuration>

编辑2:

我刚刚意识到,如果我添加一个默认架构<property name="hibernate.default_schema">,它可以正常工作,但仅适用于此架构。

编辑3:

它适用于旧版本的Hibernate工具(3.6.0.M1-v20120827-0757-H1125)。现在我很困惑。

2 个答案:

答案 0 :(得分:0)

试试这个配置:

<!-- Database connection settings -->

org.postgresql.Driver JDBC:在PostgreSQL://主机:端口/数据库 Postgres的 密码

1

org.hibernate.dialect.PostgreSQLDialect

螺纹

org.hibernate.cache.internal.NoCacheProvider

&#13;
&#13;
Try out this config:
<session-factory>

    <!-- Database connection settings -->
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://host:port/database</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">password</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache  -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

 </session-factory>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

所以我发现它可能是JBoss Tools中的一个错误。所以我开了一张票:https://issues.jboss.org/plugins/servlet/mobile#issue/JBIDE-19830