2
liefern Wenn ich versuche TransaktionUnsupportedOperationException: Die Anwendung muss JDBC-Verbindungen JPA Hibernate Frühling JDBC
entityManager.getTransaction().begin();
in AbstractDao, bekomme ich
java.lang.UnsupportedOperationException: The application must supply JDBC connections
Mein 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>
zu beginnen
Meine 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 Bohne:
@Bean
public EntityManagerFactory entityManagerFactory(){
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("pu");
return entityManagerFactory;
}
EntityManager Bohne:
@Bean
public EntityManager entityManager(){
return entityManagerFactory.createEntityManager();
}