读取模式时 Hibernate 配置错误
Hibernate configuration error while reading schema
嘿 Whosebug,
我试图将 Hibernate 配置添加到我的工作区,以便对我的数据库进行逆向工程。
当我在 'Hibernate Configurations' 视图中打开数据库点时,我得到一个 Reading schema error: null
,但有以下异常:
java.lang.NullPointerException
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.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.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
有人遇到过这种情况吗?
我正在 运行 全新安装 Eclipse Luna / 最新 JBoss 工具并尝试连接到 PostgreSQL 9.3 数据库。
提前致谢
编辑:
我的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)。现在我很困惑。
试试这个配置:
<!-- Database connection settings -->
org.postgresql.Driver
jdbc:postgresql://主机:port/database
后置数据库
密码
1
org.hibernate.dialect.PostgreSQLDialect
线程
org.hibernate.cache.internal.NoCacheProvider
真
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>
所以我发现它可能是 JBoss 工具中的错误。于是开了个票:https://issues.jboss.org/plugins/servlet/mobile#issue/JBIDE-19830
嘿 Whosebug,
我试图将 Hibernate 配置添加到我的工作区,以便对我的数据库进行逆向工程。
当我在 'Hibernate Configurations' 视图中打开数据库点时,我得到一个 Reading schema error: null
,但有以下异常:
java.lang.NullPointerException
at org.hibernate.eclipse.console.workbench.LazyDatabaseSchemaWorkbenchAdapter.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.run(DeferredTreeContentManager.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
有人遇到过这种情况吗? 我正在 运行 全新安装 Eclipse Luna / 最新 JBoss 工具并尝试连接到 PostgreSQL 9.3 数据库。
提前致谢
编辑:
我的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)。现在我很困惑。
试试这个配置:
<!-- Database connection settings -->
org.postgresql.Driver jdbc:postgresql://主机:port/database 后置数据库 密码
1
org.hibernate.dialect.PostgreSQLDialect
线程
org.hibernate.cache.internal.NoCacheProvider
真
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>
所以我发现它可能是 JBoss 工具中的错误。于是开了个票:https://issues.jboss.org/plugins/servlet/mobile#issue/JBIDE-19830