2
私はトランザクションにAbstractDaoでにUnsupportedOperationException:JDBC接続JPA Hibernateの春のJDBC
entityManager.getTransaction().begin();
を開始しようとすると、私が取得
java.lang.UnsupportedOperationException: The application must supply JDBC connections
私のpersistence.xmlを供給しなければならないアプリケーション
<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="pu" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value = "create-drop"/>
</properties>
</persistence-unit>
</persistence>
私のhibernate.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ewp?createIfNotExist=true
jdbc.username=root
jdbc.password=root
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.format_sql=false
hibernate.hbm2ddl.auto=create-drop
のEntityManagerFactory豆:
@Bean
public EntityManagerFactory entityManagerFactory(){
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("pu");
return entityManagerFactory;
}
のEntityManager豆:
@Bean
public EntityManager entityManager(){
return entityManagerFactory.createEntityManager();
}