Thanks very much,
I created HibernateUtil with static block:
Code:
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
log.error("Initial SessionFactory creation failed.", ex);
throw new ExceptionInInitializerError(ex);
}
}
and I have a method:
Code:
public static Session getSession( String instance ) throws HibernateException, SQLException {
Connection connection = DriverManager.getConnection( url, instance, psw );
Session session = sessionFactory.openSession(connection);
return session;
}
I have url and psw initialized from beans.
And it works :)
Thanks very much again.