Nao consigo configurar o hibernate

Ola, tudo bem? Estou a tentar iniciar uma aplicacao usando o hibernate, mas nao estou sabendo configura- lo adequadamente… estou com uma ExceptionInInitializerError nas
seguintes linhas de codigo .

static {  
        try {  
            sessionFactory = configuration  
                .configure()  
                .buildSessionFactory();  
              
        } catch (Throwable ex) {  
            // Log exception!  
            throw new ExceptionInInitializerError(ex);  
        }  
    }  

Segundo li em alguns tutorais isso se deve ao fato de nao ter configurado o arquivo hibernate.cfg.xml… mas dentro do hibernate ha varios arquivos com este nome …
qual deles eu configuro?? Quais os outros arquivos que devo configurar para que meu hibernate encontre o banco??

sucesso a todos.

[i]Este arquivo hibernate.cfg.xml vc deve cria-lo dentro do seu src …

Uma estrutura básica deste xml utilizando banco MySQL é a seguinte :[/i]

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
	"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
	<session-factory>
		<!-- Configurações Hibernate -->
		<property name="hibernate.connection.username">Login do usuario do banco</property>
		<property name="hibernate.connection.password">Senha do usuario do banco</property>
		<property name="hibernate.connection.url">jdbc:mysql://localhost/DATABASE</property>
		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
		
		<property name="hibernate.hbm2ddl.auto">update</property>
		
		<property name="show_sql">true</property>
		<property name="format_sql">true</property>
		
		<!-- Entidades -->
		
	</session-factory>
</hibernate-configuration>


Vale lembrar também que o .jar do mysql connector deve estar na lib :smiley:

Olá, consegui fazer ele ao menos reconhecer q estou a tentar inserir a entidade cliente… como estou a usar annotations entao eu pude configurar diretamente na minha classe que cria a sessao.

public class SessionManager {

	private static SessionFactory sessionFactory;  
	private static Configuration configuration;
    
    static {  
        try {  
        	configuration = new Configuration();
            sessionFactory = configuration  
               .setProperty("hibernate.connection.username", "root") 
               .setProperty("hibernate.connection.password", "123456") 
               .setProperty("hibernate.connection.url", "jdbc:mysql://localhost/TESTEDB") 
               .setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver") 
               .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect") 
               .setProperty("hibernate.hbm2ddl.auto", "update") 
               .setProperty("show_sql", "true") 
               .setProperty("format_sql", "true") 
               .addAnnotatedClass(BasicEntity.class)
               .addAnnotatedClass(Client.class)
               .buildSessionFactory();
        } catch (Throwable ex) {  
            // Log exception!  
        	ex.printStackTrace();
            throw new ExceptionInInitializerError(ex);  
        }  
    }  
      
    public static Session getSession() throws HibernateException {  
        return sessionFactory.openSession();  
    }  
    
    public static Configuration getConfiguration() {  
        if( configuration == null )  
            configuration =  new Configuration();  
        return configuration;  
    }  
}

Porém ainda encontro problemas. . quando tento persistir ele nao joga excessao nenhuma, mas tambem nao insere no banco… eis as minhas classes dao e entidades:

public class CrudDao <ENTITY extends BasicEntity>{
	
	public void persist(ENTITY entity) throws SQLException{
		Session session = SessionManager.getSession();
		session.persist(entity);
		session.flush();
		
		SessionManager.getConfiguration().buildSettings().getConnectionProvider().
		getConnection().commit();
	}
	
	public  void delete(ENTITY entity) throws SQLException{
		Session session = SessionManager.getSession();
		session.delete(entity);
		
		session.flush();
		
		SessionManager.getConfiguration().buildSettings().getConnectionProvider().
		getConnection().commit();
	}

}
public class ClientDao  extends CrudDao<Client>{

}

Agora minha entidade . que estende a basicEntity

@MappedSuperclass
public abstract class BasicEntity {
   
	public abstract Long getId();
	
	public abstract void setId(Long id);
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BasicEntity other = (BasicEntity) obj;
		if (getId() == null) {
			if (other.getId() != null)
				return false;
		} else if (!getId().equals(other.getId()))
			return false;
		return true;
	}
}
@Entity(name = "cliente")
public class Client extends BasicEntity{
	
	@Id
	@Column(name = "ID")
	private Long id;
	
	@Column(name="NOME")
	private String name;
	
	@Column(name="CNPJ")
	private String cnpj;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCnpj() {
		return cnpj;
	}

	public void setCnpj(String cnpj) {
		this.cnpj = cnpj;
	}
	
	public Long getId(){
		return id;
	}
	
	public void setId(Long id){
		this.id = id;
	}

}

obs: id é auto increment mas da erro se eu tento inserir sem um id… nao sei se essa informacao é util ou nao…
a unica coisa que retorna no console quando tento salvar um cliente é …

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Alguem sabe o q pode ser isso?

desde ja . agradeco.