These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: A little problem for you, a big one for me
PostPosted: Wed Dec 07, 2011 7:59 am 
Newbie

Joined: Wed Dec 07, 2011 7:36 am
Posts: 1
Location: Uruguay
Hello!

I'm starting with this great tool and so I been trying to make it work but...

It keeps telling me: Configured SessionFactory: null

I have this config file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:sqlserver://myserver:1433</property>
        <property name="hibernate.connection.username">user</property>
        <property name="hibernate.connection.password">password</property>

        <property name="hibernate.connection.pool_size">1</property>

        <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>

        <property name="hibernate.show_sql">true</property>
<!--    <property name="hibernate.format_sql">true</property>-->
        <property name="hibernate.hbm2ddl.auto">create-drop</property>

        <mapping resource="mapeos/Contacto.hbm.xml"/>
    </session-factory>
</hibernate-configuration>


And just this mapping file:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC '-//Hibernate/Hibernate Mapping DTD 3.0//EN' 'http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd'>
<hibernate-mapping package="pruebahibernate">
    <class name="Contacto" table="CONTACTOS">
        <id name="id" column="ID">
            <generator class="native" />
        </id>
        <property name="nombre" type="string" column="NOMBRE" />
        <property name="email" />
        <property name="telefono" />
    </class>
</hibernate-mapping>


The class I want to persist is this:

Code:
package pruebahibernate;

public class Contacto {

    private long id;
    private String nombre;
    private String email;
    private String telefono;

    public Contacto() {
    }

    public Contacto(String nombre, String email, String telefono) {
        this.nombre = nombre;
        this.email = email;
        this.telefono = telefono;
    }

    //<editor-fold defaultstate="collapsed" desc="Getters & Setters">
    public long getId() {
        return id;
    }

    private void setId(long id) {
        this.id = id;
    }
   
    public String getNombre() {
        return this.nombre;
    }

    public String getEmail() {
        return this.email;
    }

    public String getTelefono() {
        return this.telefono;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setTelefono(String telefono) {
        this.telefono = telefono;
    }
    //</editor-fold>
}


And the class that calls Hibernate is this:

Code:
package pruebahibernate;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

    private static final SessionFactory sessionFactory;
   
    static{
        try{
        sessionFactory = new Configuration().configure().buildSessionFactory();
       
        }catch(HibernateException he){
            System.err.println("Error: " + he);
           throw new ExceptionInInitializerError(he);
        }
    }
   
    public static SessionFactory getSessionFactory(){
        return sessionFactory;
    }
}


Like UB40 says: Where did I go wrong? Why is SessionFactory null?

Thank you in advance.

_________________
--

A/P Mauricio López
Punta del Este - Uruguay


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.