Messages are now loaded from the db!
This commit is contained in:
parent
5626f77b5d
commit
57a2f28ad3
2 changed files with 4 additions and 0 deletions
|
@ -22,6 +22,8 @@
|
||||||
value="org.hibernate.transaction.JDBCTransactionFactory" />
|
value="org.hibernate.transaction.JDBCTransactionFactory" />
|
||||||
<property name="hibernate.current_session_context_class"
|
<property name="hibernate.current_session_context_class"
|
||||||
value="thread" />
|
value="thread" />
|
||||||
|
<property name="hibernate.enable_lazy_load_no_trans"
|
||||||
|
value="true" />
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
|
@ -6,6 +6,7 @@ import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.Persistence;
|
import javax.persistence.Persistence;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
|
||||||
import io.github.norbipeti.chat.server.db.domain.*;
|
import io.github.norbipeti.chat.server.db.domain.*;
|
||||||
|
@ -51,6 +52,7 @@ public class DataProvider implements AutoCloseable {
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
TypedQuery<T> query = em.createQuery("SELECT x FROM " + cl.getSimpleName() + " x", cl);
|
TypedQuery<T> query = em.createQuery("SELECT x FROM " + cl.getSimpleName() + " x", cl);
|
||||||
List<T> results = query.getResultList();
|
List<T> results = query.getResultList();
|
||||||
|
Hibernate.initialize(results);
|
||||||
em.close();
|
em.close();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue