- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人知道为什么会这样吗?我正在使用 Hibernate、Mysql、Maven、Spring。我查看了每篇文章,但找不到解决方案。谢谢:)
Class Libro
package com.webservice.serviceDos;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "libros")
public class Libro implements java.io.Serializable
{
private int libroIsbn;
private String libroAutor;
private String libroTitulo;
private String libroTema;
public Libro()
{}
public Libro(int isbn, String autor, String titulo,String tema)
{
this.libroIsbn=isbn;
this.libroAutor=autor;
this.libroTitulo=titulo;
this.libroTema=tema;
}
@Id
@Column(name = "LIBRO_ISBN", unique = true, nullable = false, precision = 5, scale = 0)
public int getLibroIsbn()
{
return this.libroIsbn;
}
public void setLibroIsbn(int isbn)
{
this.libroIsbn=isbn;
}
@Column(name = "LIBRO_AUTOR", nullable = false, length = 50)
public String getLibroAutor()
{
return this.libroAutor;
}
public void setLibroAutor(String autor) {
this.libroAutor = autor;
}
@Column(name = "LIBRO_TITULO", nullable = false, length = 50)
public String getLibroTitulo()
{
return this.libroTitulo;
}
public void setLibroTitulo(String titulo) {
this.libroTitulo = titulo;
}
@Column(name = "LIBRO_TEMA", nullable = false, length = 50)
public String getLibroTema()
{
return this.libroTema;
}
public void setLibroTema(String tema) {
this.libroTema = tema;
}
// public String toString() {
// return "Isbn: '" + this.libroIsbn + "' Autor: '" + this.libroAutor + "' Titulo: '" + this.libroTitulo + " 'Tema: '" + this.libroTema + "'";
// }
}
类 LibroDaoInterface
package com.webservice.serviceDos;
import java.io.Serializable;
import java.util.List;
public interface LibroDaoInterface<T, Id extends Serializable>
{
public void persist(T entity);
public T findById(int id);
public void delete(T entity);
public List<T> findAll();
public void deleteAll();
}
图书馆
package com.webservice.serviceDos;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import com.webservice.serviceDos.Libro;
public class LibroDao implements LibroDaoInterface<Libro, String>
{
private Session currentSession;
private Transaction currentTransaction;
public LibroDao(){}
public Session openCurrentSession()
{
currentSession = getSessionFactory().openSession();
return currentSession;
}
public Session OpenCurrentSessionwithTransaction()
{
currentSession = getSessionFactory().openSession();
currentTransaction = currentSession.beginTransaction();
return currentSession;
}
public void closeCurrentSession()
{
currentSession.close();
}
public void closeCurrentSessionwithTransaction()
{
currentTransaction.commit();
currentSession.close();
}
public static SessionFactory getSessionFactory()
{
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
SessionFactory sessionFactory = configuration.buildSessionFactory(builder.build());
return sessionFactory;
}
public Session getCurrentSession()
{
return currentSession;
}
public void setCurrentSession(Session currentSession)
{
this.currentSession = currentSession;
}
public Transaction getSessionTransaction()
{
return currentTransaction;
}
public void setCurrentTransaction(Transaction currentTransaction)
{
this.currentTransaction=currentTransaction;
}
public void persist(Libro entity)
{
getCurrentSession().save(entity);
}
public Libro findById(int id)
{
Libro libro = (Libro)getCurrentSession().get(Libro.class, id);
return libro;
}
public void delete(Libro entity)
{
getCurrentSession().delete(entity);
}
@SuppressWarnings("unchecked")
public List<Libro> findAll()
{
List<Libro> libros = (List<Libro>)getCurrentSession().createQuery("from libros").list();
return libros;
}
public void deleteAll()
{
List<Libro> entityList = findAll();
for(Libro entity : entityList)
{
delete(entity);
}
}
}
图书馆服务
package com.webservice.serviceDos;
import java.util.List;
import com.webservice.serviceDos.Libro;
import com.webservice.serviceDos.LibroDao;
import org.hibernate.exception.JDBCConnectionException;
public class LibroService
{
public static LibroDao libroDao;
public LibroService()
{
libroDao = new LibroDao();
}
public void persist(Libro entity)
{
try
{
libroDao.OpenCurrentSessionwithTransaction();
libroDao.persist(entity);
libroDao.closeCurrentSessionwithTransaction();
}
catch(JDBCConnectionException e)
{
System.out.println(e);
}
}
public Libro findById(int id)
{
libroDao.openCurrentSession();
Libro libro = libroDao.findById(id);
libroDao.closeCurrentSession();
return libro;
}
public void delete(int id)
{
libroDao.OpenCurrentSessionwithTransaction();
Libro libro = libroDao.findById(id);
libroDao.delete(libro);
libroDao.closeCurrentSessionwithTransaction();
}
public List<Libro> findAll()
{
libroDao.openCurrentSession();
List<Libro> libros = libroDao.findAll();
libroDao.closeCurrentSession();
return libros;
}
public void deleteAll()
{
libroDao.OpenCurrentSessionwithTransaction();
libroDao.deleteAll();
libroDao.closeCurrentSessionwithTransaction();
}
public LibroDao libroDao()
{
return libroDao;
}
}
hibernate .cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/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/biblioteca</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">1234</property>
<property name="hibernate.hmb2dll.auto">update</property>
<property name="show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping class="com.webservice.serviceDos.Libro"/>
</session-factory>
</hibernate-configuration>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webservice</groupId>
<artifactId>serviceDos</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>serviceDos</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
</project>
错误
ago 28, 2016 4:59:16 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
ago 28, 2016 4:59:16 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
ago 28, 2016 4:59:16 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
ago 28, 2016 4:59:16 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
ago 28, 2016 4:59:16 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
ago 28, 2016 4:59:16 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
ago 28, 2016 4:59:16 PM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
ago 28, 2016 4:59:16 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
ago 28, 2016 4:59:16 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/biblioteca]
ago 28, 2016 4:59:16 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=root, password=****}
ago 28, 2016 4:59:16 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
ago 28, 2016 4:59:16 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
ago 28, 2016 4:59:17 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
ago 28, 2016 4:59:17 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
ago 28, 2016 4:59:17 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
ago 28, 2016 4:59:17 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Exception in thread "main" org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:401)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
at com.webservice.serviceDos.LibroDao.getSessionFactory(LibroDao.java:49)
at com.webservice.serviceDos.LibroDao.OpenCurrentSessionwithTransaction(LibroDao.java:29)
at com.webservice.serviceDos.LibroService.persist(LibroService.java:23)
at com.webservice.serviceDos.App.main(App.java:14)
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:138)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:403)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:520)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:148)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
... 7 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135)
... 16 more
Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
at org.hibernate.bytecode.internal.javassist.BytecodeProviderImpl.getProxyFactoryFactory(BytecodeProviderImpl.java:58)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactoryInternal(PojoEntityTuplizer.java:244)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:222)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:212)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:80)
... 21 more
Caused by: java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 26 more
最佳答案
Caused by: java.lang.NoClassDefFoundError: javassist/util/proxy/MethodFilter
您需要包括 javassist在你的项目中。添加到 pom.xml :
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
关于java - 无法获取 org.hibernate.persister.entity.SingleTableEntityPersister 的构造函数 - BuldSession 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39195283/
我通过 spring ioc 编写了一些 Rest 应用程序。但我无法解决这个问题。这是我的异常(exception): org.springframework.beans.factory.BeanC
我对 TestNG、Spring 框架等完全陌生,我正在尝试使用注释 @Value通过 @Configuration 访问配置文件注释。 我在这里想要实现的目标是让控制台从配置文件中写出“hi”,通过
为此工作了几个小时。我完全被难住了。 这是 CS113 的实验室。 如果用户在程序(二进制计算器)结束时选择继续,我们需要使用 goto 语句来到达程序的顶部。 但是,我们还需要释放所有分配的内存。
我正在尝试使用 ffmpeg 库构建一个小的 C 程序。但是我什至无法使用 avformat_open_input() 打开音频文件设置检查错误代码的函数后,我得到以下输出: Error code:
使用 Spring Initializer 创建一个简单的 Spring boot。我只在可用选项下选择 DevTools。 创建项目后,无需对其进行任何更改,即可正常运行程序。 现在,当我尝试在项目
所以我只是在 Mac OS X 中通过 brew 安装了 qt。但是它无法链接它。当我尝试运行 brew link qt 或 brew link --overwrite qt 我得到以下信息: ton
我在提交和 pull 时遇到了问题:在提交的 IDE 中,我看到: warning not all local changes may be shown due to an error: unable
我跑 man gcc | grep "-L" 我明白了 Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more inf
我有一段代码,旨在接收任何 URL 并将其从网络上撕下来。到目前为止,它运行良好,直到有人给了它这个 URL: http://www.aspensurgical.com/static/images/a
在过去的 5 个小时里,我一直在尝试在我的服务器上设置 WireGuard,但在完成所有设置后,我无法 ping IP 或解析域。 下面是服务器配置 [Interface] Address = 10.
我正在尝试在 GitLab 中 fork 我的一个私有(private)项目,但是当我按下 fork 按钮时,我会收到以下信息: No available namespaces to fork the
我这里遇到了一些问题。我是 node.js 和 Rest API 的新手,但我正在尝试自学。我制作了 REST API,使用 MongoDB 与我的数据库进行通信,我使用 Postman 来测试我的路
下面的代码在控制台中给出以下消息: Uncaught DOMException: Failed to execute 'appendChild' on 'Node': The new child el
我正在尝试调用一个新端点来显示数据,我意识到在上一组有效的数据中,它在数据周围用一对额外的“[]”括号进行控制台,我认为这就是问题是,而新端点不会以我使用数据的方式产生它! 这是 NgFor 失败的原
我正在尝试将我的 Symfony2 应用程序部署到我的 Azure Web 应用程序,但遇到了一些麻烦。 推送到远程时,我在终端中收到以下消息 remote: Updating branch 'mas
Minikube已启动并正在运行,没有任何错误,但是我无法 curl IP。我在这里遵循:https://docs.traefik.io/user-guide/kubernetes/,似乎没有提到关闭
每当我尝试docker组成任何项目时,都会出现以下错误。 我尝试过有和没有sudo 我在这台机器上只有这个问题。我可以在Mac和Amazon WorkSpace上运行相同的容器。 (myslabs)
我正在尝试 pip install stanza 并收到此消息: ERROR: No matching distribution found for torch>=1.3.0 (from stanza
DNS 解析看起来不错,但我无法 ping 我的服务。可能是什么原因? 来自集群中的另一个 Pod: $ ping backend PING backend.default.svc.cluster.l
我正在使用Hibernate 4 + Spring MVC 4当我开始 Apache Tomcat Server 8我收到此错误: Error creating bean with name 'wel
我是一名优秀的程序员,十分优秀!