我们正在尝试从 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>
我们的持久化单元如下所示:
<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>
升级后我们收到以下错误:
[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
既然 PersistenceUnit 上的所有信息都可用,为什么 Hibernate 会尝试解析 JNDI 名称?我们对旧版本没有任何问题。
无论如何,我们如何指定 NamingFactory?(和哪一个?)