问题描述
假设ejb-jar具有以下persistence.xml配置:
Assuming an ejb-jar with the following persistence.xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="com.mystrotv.mdn.admanager.entity">
<jta-data-source>/dataSource/MystroDS_Tx</jta-data-source>
<properties>
<property name="jboss.entity.manager.jndi.name" value="java:/EntityManagers/AdManagerPersistenceContext"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/EntityManagers/AdManagerPersistenceUnit"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.max_fetch_depth" value="5"/>
<property name="hibernate.validator.apply_to_ddl" value="false" />
<property name="hibernate.validator.autoregister_listeners" value="false" />
</properties>
</persistence-unit>
</persistence>
我想基于JTA数据源定义休眠方言.如果是oracle,则使用下面指示的方言;如果是postgres,则使用其他方言.有谁知道如何做到这一点,或者可以向我指出如何做到这一点的文档? Google未能提供所需的信息.该应用程序将部署在JBoss应用程序服务器中,但我也希望支持其他应用程序服务器.此外,我们有两种部署模型,一种使用postgres,一种使用oracle和Id,而不必构建两个Ears来支持配置文件中的一行差异.
I would like to define the hibernate dialect based on the JTA data source. If it is oracle, I use the dialect indicated below, if postgres, I use a different dialect. Does anyone know how to do this or can point me to documentation on how to do it? Google has failed to turn up the needed information. The app will be deployed in a JBoss app server but I want to support other app servers as well. Furthermore, we have two deployment models, one uses postgres and one uses oracle and Id rather not have to build two Ears to support a one line difference in a config file.
先谢谢了.
推荐答案
在我发布问题后,我找到了答案;
And just after I post the question, I find the answer;
http://docs.jboss .org/hibernate/core/3.6/reference/zh-CN/html_single/#portability-dialectresolver
具体来说,如果未指定方言,则从3.2版本开始的休眠版本应从JTA数据源中自动检测到它,因此正确的过程是完全不使用方言规范.
Specifically, if a dialect is not specified, versions of hibernate from 3.2 on should auto-detect it from the JTA data source and thus the correct procedure is to leave the dialect specification off the properties altogether.
这篇关于有没有一种方法可以基于jta-data-source配置Hibernate方言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!