Mat*_*teo 16 hibernate hibernate-tools
我们正在尝试从Hibernate 3.6.7升级到4.1.2,将Hibernate Tools 3.2.0升级到3.5.0
我们使用Ant生成数据库创建脚本:
<hibernatetool destdir="${target}">
<jpaconfiguration persistenceunit="stdcmpOrderPersistenceUnit" propertyfile="@{propertyfile}"/>
<classpath refid="@{classpathid}"/>
<!-- the file name is relative to $destdir -->
<hbm2ddl outputfilename="@{output}" format="true" export="false" drop="false"/>
</hibernatetool>
Run Code Online (Sandbox Code Playgroud)
我们的持久性单元看起来像这样:
<persistence-unit name="stdcmpOrderPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/lakshmi_stdcmp</jta-data-source>
<mapping-file>META-INF/stdcmpOrderNamedQueries.xml</mapping-file>
<class>ch.ethz.id.wai.lakshmi.stdcmp.persistency.PersistentOrder</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)
升级后,我们收到以下错误:
[hibernatetool] org.hibernate.service.jndi.JndiException: Error parsing JNDI name [jdbc/lakshmi_stdcmp]
[hibernatetool] javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
Run Code Online (Sandbox Code Playgroud)
为什么Hibernate会尝试解析JNDI名称,因为PersistenceUnit上的所有信息都可用?我们对旧版本没有任何问题.
在任何情况下,我们如何指定NamingFactory?(哪一个?)
小智 57
我遇到了类似的问题,特别是导致"解析JNDI名称时出错",只需从session-factory标签中删除空名称属性即可轻松修复.
我的hibernate.cfg.xml了
<session-factory name="">
Run Code Online (Sandbox Code Playgroud)
这是自动生成的,所以我刚删除了nameattrib.
此修复程序可在此处找到:https://forum.hibernate.org/viewtopic.php?f = 1&t = 1014760
问题出在您的休眠工具上,您已将休眠工具配置为使用持久单元,该单元具有通过 JNDI 配置的 jta 数据源。为了让 ant 任务与 JNDI 对话,它需要命名工厂 url 和提供者。使用配置数据源的应用程序服务器的命名工厂类。
希望能帮助到你。
| 归档时间: |
|
| 查看次数: |
28165 次 |
| 最近记录: |