早期我使用JPA爲我的應用程序開發了ORM。在peristenc.xml中,我定義了hibernate provider並使用非JTA-DataSource。 JPA可以在沒有休眠提供程序的情況下運行。那麼我省略了persistence.xml中的hibernate代碼。然後我部署了,在控制檯中我收到以下信息。JPA可以在沒有休眠提供程序的情況下運行。
18:19:56,028 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-6) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
18:19:56,032 INFO [org.hibernate.dialect.Dialect] (MSC service thread 1-6) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
18:19:56,033 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-6) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactor
但我沒有提到在我的應用程序中關於休眠的地方。
** 的persistence.xml ** *
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
<persistence-unit name="StudentManagementSystem" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:jboss/datasources/studentDS</non-jta-data-source>
<class>com.dms.entity.student.StudentDetail</class>
<class>com.dms.entity.student.MarkDetail</class>
<class>com.dms.entity.student.PRDSemesterDetail</class>
<class>com.dms.entity.admin.LoginDetail</class>
</persistence-unit>
</persistence>
*非JTA-數據源*
<datasource jndi-name="java:jboss/datasources/studentDS" pool-name="studentDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/exercise</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>student</user-name>
<password>student</password>
</security>
</datasource>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</xa-datasource-class>
</driver>