Messages are now loaded from the db!

This commit is contained in:
Norbi Peti 2016-07-28 11:54:44 +02:00
parent 5626f77b5d
commit 57a2f28ad3
2 changed files with 4 additions and 0 deletions

View file

@ -22,6 +22,8 @@
value="org.hibernate.transaction.JDBCTransactionFactory" />
<property name="hibernate.current_session_context_class"
value="thread" />
<property name="hibernate.enable_lazy_load_no_trans"
value="true" />
</properties>
</persistence-unit>
</persistence>

View file

@ -6,6 +6,7 @@ import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import io.github.norbipeti.chat.server.db.domain.*;
@ -51,6 +52,7 @@ public class DataProvider implements AutoCloseable {
EntityManager em = emf.createEntityManager();
TypedQuery<T> query = em.createQuery("SELECT x FROM " + cl.getSimpleName() + " x", cl);
List<T> results = query.getResultList();
Hibernate.initialize(results);
em.close();
return results;
}