0

当在 seam 中使用休眠配置配置 jpa 时,THIN 驱动程序不支持 Null 用户或密码

组件.xml

<persistence:hibernate-session-factory   name="hibernateSessionFactory" cfg-resource-name="hibernate.cfg.xml"/>
<persistence:managed-hibernate-session name="session" 
                 auto-create="true"
 session-factory-jndi-name="java:/mobeeSessionFactory"/>

休眠.cfg.xml

<hibernate-configuration>
 <session-factory name="java:/mobeeSessionFactory">
  <property name="hibernate.connection.pool_size">10</property>
  <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:mobee</property>
  <property name="hibernate.connection.username">mobeemigrate</property>
  <property name="hibernate.show_sql">true</property>
 <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
  <property name="hibernate.format_sql">true</property>

  <property name="hibernate.default_entity_mode">pojo</property>
  <property name="hibernate.session_factory_name">java:/mobeeSessionFactory</property>
  <property name="hibernate.connection.datasource">mobeeadminDataSource</property>
  <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
  <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  <property name="hibernate.transaction.auto_close_session">false</property>
  <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
  <property name="hibernate.transaction.flush_before_completion">true</property>
  <property name="hibernate.hbm2ddl.auto">create</property>
  <!-- Here are the mappings -->
  <mapping class="tempCustomers" package="com.manam.mobee.persist.entity.TempCustomers"/>
  <mapping class="tempAccounts" package="com.manam.mobee.persist.entity.TempAccounts"/>
 </session-factory>
</hibernate-configuration>

项目名称-ds.xml

<local-tx-datasource>
  <jndi-name>mobeeadminDataSource</jndi-name>
  <use-java-context>false</use-java-context>
  <connection-url>jdbc:oracle:thin:@localhost:1521:mobee</connection-url>
  <driver-class>oracle.jdbc.OracleDriver</driver-class>
  <user-name>mobeemigrate</user-name>
  <password>mobeemigrate</password>
 </local-tx-datasource>
4

2 回答 2

0

中缺少密码hibernate.cfg.xml

要修复,请在 hibernate.cfg.xml 文件中包含以下内容,如下所示:

  <property name="hibernate.connection.password">mobeemigrate</property>

休眠.cfg.xml

<hibernate-configuration>
 <session-factory name="java:/mobeeSessionFactory">
  <property name="hibernate.connection.pool_size">10</property>
  <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:mobee</property>
  <property name="hibernate.connection.username">mobeemigrate</property>
  <property name="hibernate.connection.password">mobeemigrate</property>
  <property name="hibernate.show_sql">true</property>
 <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
  <property name="hibernate.format_sql">true</property>

  <property name="hibernate.default_entity_mode">pojo</property>
  <property name="hibernate.session_factory_name">java:/mobeeSessionFactory</property>
  <property name="hibernate.connection.datasource">mobeeadminDataSource</property>
  <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
  <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  <property name="hibernate.transaction.auto_close_session">false</property>
  <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
  <property name="hibernate.transaction.flush_before_completion">true</property>
  <property name="hibernate.hbm2ddl.auto">create</property>
  <!-- Here are the mappings -->
  <mapping class="tempCustomers" package="com.manam.mobee.persist.entity.TempCustomers"/>
  <mapping class="tempAccounts" package="com.manam.mobee.persist.entity.TempAccounts"/>
 </session-factory>
</hibernate-configuration>
于 2012-12-07T13:09:15.580 回答
0

您的 hibernate.cfg.xml 具有以下属性:

<property name="hibernate.connection.username">mobeemigrate</property>

但不是对应的密码一:

<property name="hibernate.connection.password">mobeemigrate</property>
于 2012-12-07T13:09:45.343 回答