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: Schema Management
PostPosted: Sun Oct 10, 2010 1:40 pm 
Newbie

Joined: Sun Oct 10, 2010 1:29 pm
Posts: 2
I am pretty new to Hibernate and I am working on a project where I would like to be manage my schema changes from within my code to allow for doing things like populating default values, etc. My application is a JSF 2.0 based web application that I am going to distribute via a war file. What I would like, is to use a ServletContextListener to install my database on application startup as well as perform any database upgrades as needed.

So here is my question, is there a way to use Hibernate to create my tables with with createSQLQuery? The problem is when I attempt to get a session using my HibernateUtil class, it tries to spin up all the mappings, which fail because the table don't yet exist. So, my question is can I do this without using hibernate.hbm2ddl.auto? As I said, I am pretty new with Hibernate, so if this is a dumb question I apologize ahead of time.

Thanks

Here is my HibernateUtil class

Code:
public class HibernateUtil {
    private static final SessionFactory sessionFactory;

    static
    {
        try
        {
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static void close()
    {
        if (sessionFactory != null)
            sessionFactory.close();

    }

    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}


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.