我使用hibernate创建hibernate.cgf.xml
和映射文件。
我为实体和hibernateUtil.java
创建了一个类java,当我运行test main时,它生成了这个:
Exception in thread "main" net.sf.hibernate.MappingException: No persister for: fr.hibernate.projet.model.Employe
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:763)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
at fr.hibernate.projet.test.Test.main(Test.java:32)
数据库仍为空。
答案 0 :(得分:1)
“no persiter”通常表示给定类型没有映射定义。您是否在程序中加载了映射定义?
编辑:您的配置文件可能存在问题。它必须位于可以找到它的路径上。 Google