Hibernate绑定到Weblogic的JNDI上的问题(尤其请robbin指教)
1、首先在Weblogic上配置一个连接池quickstart。JNDI名称也是quickstart。
2、编写一个Weblogic的启动类。该类完全参考Hibernate站点上的例子。http://hibernate.bluemars.net/74.html
3、Hibernate的配置文件定义如下:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">quickstart</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="OrderBase.hbm.xml"/>
</session-factory>
</hibernate-configuration>
4、将POJO持久类、启动类和映射文件打包到一个文件POJO.jar;同时将Hibernate需要的Jar文件和POJO.jar文件放到Weblogic的启动CLASSPATH上去。
4、启动Weblogic,配置一个启动类。指向我们刚创建的Hibernate启动类;
5、关闭Weblogic,重新启动,结果如下:
开始绑定Hibernate对象.
10:28:18,593 INFO Environment:377 - Hibernate 2.0 beta 5
10:28:18,593 INFO Environment:406 - hibernate.properties not found
10:28:18,593 INFO Environment:426 - using CGLIB reflection optimizer
10:28:18,593 INFO Environment:436 - JVM proxy support: true
10:28:18,609 INFO Configuration:264 - Mapping resource: com/huawei/ibss/po/Orde
rBase.hbm.xml
10:28:18,750 INFO Collection:166 - Mapping class: com.huawei.ibss.po.OrderBase
-> ORDERBASE
10:28:19,125 INFO SessionFactoryImpl:122 - building session factory
10:28:19,140 WARN SessionFactoryImpl:140 - No dialect set - using GenericDialec
t: The dialect was not set. Set the property hibernate.dialect.
10:28:19,140 INFO Dialect:36 - Using dialect: net.sf.hibernate.dialect.GenericD
ialect
10:28:19,156 WARN UserSuppliedConnectionProvider:24 - No connection properties
specified - the user must supply JDBC connections
10:28:19,156 INFO SessionFactoryImpl:155 - Use outer join fetching: false
10:28:19,156 INFO SessionFactoryImpl:178 - Use scrollable result sets: false
10:28:19,531 INFO SessionFactoryObjectFactory:82 - no JDNI name configured
10:28:19,531 INFO SessionFactoryImpl:272 - Query language substitutions: {}
绑定完成!
问题:明明我在Hibernate的配置文件里申明了用的是Oracle的Dialect。但是启动的时候并没有使用Oracle的。这就导致了数据库连接无法找到。连接池的配置没有问题。JNDI也可以看到。测试都可以连接数据库。
请教是什么原因?