我使用Hibernate创建了一个小型桌面项目,以了解企业模式在那里的应用方式。Hibernate 3.0 + ElementCollection类缺失
我使用的注释,并写了一个类来包装我的会话工厂
public class Hibernation {
private static final SessionFactory sessionFactory;
static{
try{
//sesionFactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
}
catch(Throwable e){
throw new ExceptionInInitializerError(e);
}
}
public static Session getSession(){
return sessionFactory.openSession();
}
}
然而,每当我尝试运行它,我得到这个错误:
引起:java.lang中.ClassNotFoundException:javax.persistence.ElementCollection
在我的类路径罐子似乎不具有内他们班
hibernate3.jar
jpa.jar
log4j-1.2.15.jar
persistence-api-1.0.jar
slf4j-log4j12-1.0.1.jar
我环顾四周,但我找不到从哪里下载它。任何想法我错过了什么jar文件?我查看了javaee.jar,其中有很多javax.persistence。***类,但它们不在那里。
在此先感谢。
请使用较新版本的Hibernate。 该版本应该大于3.5或更好地使用Hibernate 4.0。 请使用以下链接下载合适的版本http://sourceforge.net/projects/hibernate/files/ – 2012-07-16 10:02:59