Search code examples
hibernateannotationshibernate3java

Hibernate 3.0 + ElementCollection class missing


I created a small desktop project using Hibernate, to understand how enterprise patterns are applied in there.

I'm using annotations, and wrote a class to wrap my session factory

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();
    }

}

However, whenever i try to run it, I get this error:

Caused by: java.lang.ClassNotFoundException: javax.persistence.ElementCollection

The jars in my classpath do not seem to have that class inside them

hibernate3.jar
jpa.jar
log4j-1.2.15.jar
persistence-api-1.0.jar
slf4j-log4j12-1.0.1.jar

I've looked around for that class, but I can't find where to download it from. Any idea what jar file i'm missing? I looked inside javaee.jar, where there are many javax.persistence.*** clases, but its not there either.

Thanks in advance.


Solution

  • don't take javax.persistence_2.0_preview.jar from 1.2.0 OSGi bundles zip if you test Hibernate 3.5.0 beta 2, because it is not complete! For example class javax.persistence.criteria.CriteriaBuilder is missing there.

    Take following jar indeed: http://repository.jboss.org/maven2/org/hibernate/java-persistence/jpa-api/2.0-cr-1/jpa-api-2.0-cr-1.jar

    Generally it is recommended to take all hiberante 3hrd-party jars out from this repository (repository.jboss.org/maven2/org/hibernate/)

    regards G.D.