Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hibernate ORM提供程序、Netbeans 7、Glassfish(视频)_Java_Hibernate_Jpa_Jakarta Ee_Glassfish - Fatal编程技术网

Java Hibernate ORM提供程序、Netbeans 7、Glassfish(视频)

Java Hibernate ORM提供程序、Netbeans 7、Glassfish(视频),java,hibernate,jpa,jakarta-ee,glassfish,Java,Hibernate,Jpa,Jakarta Ee,Glassfish,在我所有的项目中,我对Hibernate的基本功能都有很大的问题 我有mysql服务器,有一个hiber数据库(localhost)。 有两个表:消息和用户 我有玻璃鱼3.1 我在Netbeans 7中用Hibernate框架启动了一个新项目 然后,我创建了entities和persistence.xml,PersistenceUnit 之后,我创建了Servlet,即Demo(映射为/Demo) persistence.xml: <?xml version="1.0" encoding=

在我所有的项目中,我对Hibernate的基本功能都有很大的问题

我有mysql服务器,有一个hiber数据库(localhost)。
有两个表:消息用户

我有玻璃鱼3.1

我在Netbeans 7中用Hibernate框架启动了一个新项目 然后,我创建了entities和persistence.xml,PersistenceUnit

之后,我创建了Servlet,即Demo(映射为/Demo)

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="WebApplication7PU" transaction-type="JTA">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <jta-data-source>hiberMysql</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties/>
  </persistence-unit>
</persistence>

org.hibernate.ejb.HibernatePersistence
hiberMysql
假的
hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hiber</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">haslo</property>
  </session-factory>
</hibernate-configuration>

org.hibernate.dialogue.mysqldialogue
com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/hiber
根
哈斯洛
首先,我在日志中看到:

INFO: Not binding factory to JNDI, no JNDI name configured
JNDI指示javax.sql.DataSource所在的位置。你有:

<jta-data-source>hiberMysql</jta-data-source>
hiberMysql
我认为您必须将此更改为: java:/hiberMysql

首先,我在日志中看到:

INFO: Not binding factory to JNDI, no JNDI name configured
JNDI指示javax.sql.DataSource所在的位置。你有:

<jta-data-source>hiberMysql</jta-data-source>
hiberMysql
我认为您必须将此更改为:
java:/hiberMysql

您在hibernate文件中使用的是数据源还是配置参数?因为persistence.xml建议使用名为hiberMySQL的数据源,但这不是Hibernate配置所建议的。首先,我想看看Spring来处理事务,因为代码中有一个bug,如果抛出和异常,就不会回滚事务,而只是让它保持打开状态。你的渔获物或最终应该处理它。下面是一个视频,展示了Jpa和Spring的最佳实践和设置:您在hibernate文件中使用的是数据源还是配置参数?因为persistence.xml建议使用名为hiberMySQL的数据源,但这不是Hibernate配置所建议的。首先,我想看看Spring来处理事务,因为代码中有一个bug,如果抛出和异常,就不会回滚事务,而只是让它保持打开状态。你的渔获物或最终应该处理它。这里有一个视频展示了Jpa和Spring的最佳实践和设置:谢谢,这是JNDI的问题。谢谢,这是JNDI的问题。