guice-persist

How to prevent reuse of EntityManager with guice-persist and @Transactional?

给你一囗甜甜゛ 提交于 2020-01-25 06:49:27
问题 According to this question, when using guice-persist , EntityManager is transaction-scoped. If I understand correctly, this means that a new EntityManager will be created for every transaction. When using guice-persist , it is suggested to use JpaPersistModule , which provides all the bindings, and simply inject Provider<EntityManager> into some class, like this: public class ProjectDAO { private final Provider<EntityManager> entityManagerProvider; @Inject public ProjectDAO(Provider

EclipseLink + JPA Guice Persist and Redeployments

跟風遠走 提交于 2020-01-24 01:10:08
问题 I have an infrastructure based on EclipseLink + JPA Guice Persist When I redeploy the application always I have caching problems with caching Entitys and I have to reboot the server (Oracle Weblogic 11g) .This problem is treated in a this post: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326552 But, maybe is not a bug ¿?¿? ... I managed to solve the problem as follows : Originally I have centralized everything in a GuiceModule: 1.Create the module JPAPersist 2.Binding of a Initializer class

JPA 2 + EclipseLink : Caching Issue

只愿长相守 提交于 2020-01-15 10:57:19
问题 I have a strange behavior with caching and JPA Entities (EclipseLink 2.4.1 ) + GUICE PERSIST I will not use caching, nevertheless I get randomly an old instance that has already changed in MySQL database. I have tried the following: Add @ Cacheable (false) to the JPA Entity. Disable Cache properties in the persistence.xml file : <class>MyEntity</class> <shared-cache-mode>NONE</shared-cache-mode> <properties> <property name="eclipselink.cache.shared.default" value="false"/> <property name=

JPA 2 + EclipseLink : Caching Issue

拜拜、爱过 提交于 2020-01-15 10:57:05
问题 I have a strange behavior with caching and JPA Entities (EclipseLink 2.4.1 ) + GUICE PERSIST I will not use caching, nevertheless I get randomly an old instance that has already changed in MySQL database. I have tried the following: Add @ Cacheable (false) to the JPA Entity. Disable Cache properties in the persistence.xml file : <class>MyEntity</class> <shared-cache-mode>NONE</shared-cache-mode> <properties> <property name="eclipselink.cache.shared.default" value="false"/> <property name=

Recovering from broken database connection with hibernate

痞子三分冷 提交于 2019-12-12 01:25:33
问题 I am having trouble recovering from a broken database connection. My test case uses the following libraries. guice-persist 4.0 Hibernate core 4.3.1 HikariCP-java6-2.3.9 (connection pool). My test runs a simple read in a loop with a small sleep between each read. @com.google.inject.persist.Transactional protected void simpleRead() { dao = new MyDao(....) dao.findBy(...) } The Dao acquires its entityManager like this @Inject protected com.google.inject.Provider<EntityManager> entityManager; The

Hibernate/JPA not validating against DB schema on startup

蓝咒 提交于 2019-12-10 17:46:22
问题 For some reason hibernate is not catching issues like mapping entities to tables that do not exist. My persistence.xml file looks like this... <?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <!-- A JPA Persistence Unit --> <persistence-unit name=

Guice JPA - “This connection has been closed.” error

泄露秘密 提交于 2019-12-06 07:29:21
问题 After DB dropps an idle connection or DB is down and back up I'm receiving the following error in my webapp: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not inspect JDBC autocommit mode at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1365) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1293) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:265) ... 60 more

Guice JPA - “This connection has been closed.” error

元气小坏坏 提交于 2019-12-04 12:32:25
After DB dropps an idle connection or DB is down and back up I'm receiving the following error in my webapp: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: could not inspect JDBC autocommit mode at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1365) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1293) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:265) ... 60 more Caused by: org.hibernate.exception.JDBCConnectionException: could not inspect JDBC autocommit mode at

Does Guice Persist provide transaction scoped or application managed EntityManager?

限于喜欢 提交于 2019-11-27 02:38:52
问题 We use Guice Persist to inject EntityManager in our project. E.g. public class MyDao{ @Inject EntityManager em; public void someMethod(){ //uses em instance } } But it is unclear for us how injected instance of EntityManager is about to be used. What type of EntityManager is this? (see e.g.: types of entity managers) Under the hood Guice Persist instantiates it via EntityManagerFactory.createEntityManager() so I'd say it's application-managed entity manager. But in official Wiki they write