could anyone say what s wrong with my application?
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 SessionFactory getSessionFactory() {
return sessionFactory;
}
}
public boolean insertUser(User user) {
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
session.save(user);
session.getTransaction().commit();
} catch (HibernateException he) {
session.getTransaction().rollback();
return false;
}finally{
if (session != null){
session.close();
}
}
return true;
}
This is the only method i call to insert an user in the database, and then if i try to insert another one, launch this exception:
Initial SessionFactory creation failed.java.lang.OutOfMemoryError: PermGen space
UPDATE: I don t know if there s something in hibernate.cfg but here it go:
<?xml version="1.0" encoding="UTF-8"?>
org.hibernate.dialect.MySQLDialect com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/XXXXX XXXX XXXXc thread
<!-- Connection pool C3P0 -->
<property name="hibernate.c3p0.acquire_increment">2</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.timeout">20</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">60</property>
<!-- To show sql output on the screen -->
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<!-- Mapping the tables in my schema -->
...
</session-factory>
为什么会发生这种情况以及如何纠正?
Best regards, Valter Henrique.