从Hibernate entitymanager 3.6.9移到4.1.2崩溃的mysql连接 [英] moving from Hibernate entitymanager 3.6.9 to 4.1.2 crashed mysql connection
问题描述
我知道有从3.x迁移到4.x的帖子。
然而,我无法破译和关联这些指南所说的内容我需要做我的maven依赖或我的代码。
特别是在
$ b $后操作失败bTypedQuery q = em.createQuery(blah ..);
at
列表结果= q.getResultList();
当驱动程序试图获得连接,最终成为呱呱叫
找不到合适的驱动程序...
我无法找到任何直接的答案,我是否需要
我需要对代码和我的maven依赖项进行任何更改吗?我应该习惯使用hibernate 4吗?
persistence.xml:
<?xml version =1.0encoding =UTF-8?>
< persistence xmlns =http://java.sun.com/xml/ns/persistence
version =1.0>
< persistence-unit name =z666transaction-type =RESOURCE_LOCAL>
< provider> org.hibernate.ejb.HibernatePersistence< / provider>
< class> z666.Node< / class>
<属性>
< property name =hibernate.dialectvalue =org.hibernate.dialect.MySQLInnoDBDialect/>
< property name =hibernate.connection.driver_classvalue =com.mysql.jdbc.Driver/>
< property name =hibernate.show_sqlvalue =true/>
< property name =hibernate.connection.usernamevalue =zzz/>
< property name =hibernate.connection.passwordvalue =666/>
< property name =hibernate.connection.urlvalue =jdbc:mysql:// localhost:3306 / z666/>
< property name =hibernate.max_fetch_depthvalue =3/>
< / properties>
< / persistence-unit>
< /余辉>
似乎您缺少MySQL驱动程序 mysql-connector-java-< version> .jar
当前版本是 mysql-connector-java-5.1.20.jar
。您需要一个maven依赖项,例如:
<依赖项>
< groupId> mysql< / groupId>
< artifactId> mysql-connector-java< / artifactId>
< version> 5.1.20< / version>
< /依赖关系>
我不知道Hibernate 4可以接受哪些版本,但我认为您至少需要5.1
I realise there are posts on migrating from 3.x to 4.x.
However, I am unable to decipher and correlate what those guides are saying to what I need to do with my maven dependencies or my code.
Specifically the operation failed after
TypedQuery q = em.createQuery(blah..);
at
List result = q.getResultList();
When the Driver is attempting to get connection, ending up in croaking
No suitable driver found ...
I could not find any direct answers as to whether I need to
- make changes to persistence.xml
- make changes to my code
- realign my JPA paradigm
Are there any changes I need to make to my code and my maven dependencies? Should I even bother with getting accustomed to hibernate 4?
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
version="1.0">
<persistence-unit name="z666" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>z666.Node</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.connection.username" value="zzz" />
<property name="hibernate.connection.password" value="666" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/z666" />
<property name="hibernate.max_fetch_depth" value="3" />
</properties>
</persistence-unit>
</persistence>
Seems like you are missing the MySQL driver mysql-connector-java-<version>.jar
Current version is mysql-connector-java-5.1.20.jar
. You need a maven dependency like:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.20</version>
</dependency>
I don't know what versions are acceptable for Hibernate 4 but I think you need at least 5.1
这篇关于从Hibernate entitymanager 3.6.9移到4.1.2崩溃的mysql连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!