Hibernate erro

1 resposta
Levy_Moreira

Alguém sabe o que esta ocorrendo que não consigo compilar esse código:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BojoHibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 *
 * @author Levy
 */
public class HibernateUtil implements java.io.Serializable {

    private static long serialVersionUID = 1L;
    private static HibernateUtil me;
    private SessionFactory sessionFactory;

    public HibernateUtil() {
        sessionFactory = new AnnotationConfiguration()
          .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLMyISAMDialect")
          .setProperty("hibernate.connection.driver_class", "org.gjt.mm.mysql.Driver")
          .setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/dadosh")
          .setProperty("hibernate.connection.username", "root")
          .setProperty("hibernate.connection.password", "admin")
          .setProperty("hibernate.hbm2dd1.auto", "update")
          .setProperty("hibernate.show_sql", "true")
          .setProperty("hibernate.format_sql", "true")
          .setProperty("hibernate.c2p0.acquire_increment", "1")
          .setProperty("hibernate.c2p0.idle_test_pediod", "100")
          .setProperty("hibernate.c2p0.max_size", "10")
          .setProperty("hibernate.c2p0.max_statements", "0")
          .setProperty("hibernate.c2p0..min_size", "5")
          .setProperty("hibernate.c2p0.timeout", "100")
          .addAnnotatedClass(Users.class) ///erro nesta linha 
          /*
           cannot find symbol
           symbol: method addAnnotatedClass(java.lang.Class<BojoHibernate.Users>)
           location: class org.hibernate.cfg.Configuration
          */
          .buildSessionFactory();
         // startHibernate;

    }

    public Session getSession(){
    Session toReturn = sessionFactory.openSession();
    toReturn.beginTransaction();
    return toReturn;
}

    public static HibernateUtil getInstance() {
        if (me == null) {
            me = new HibernateUtil();
        }
        return me;
    }
}

Onde esta o erro coloquei isso ///erro nesta linha
Obrigado a todos desde já.

1 Resposta

heroijapa

O Hibernate tem varios jars, talvez vc não tenha importado o de annotations

Só um chute

Criado 16 de janeiro de 2011
Ultima resposta 16 de jan. de 2011
Respostas 1
Participantes 2