I am having an issue with guice-persist and guice-servlet (http-request scoped jpa sessions) where I attempt to update an entity's value and persist that update, but the update is never persisted to the database. I have tried forcing the write with an entityManager.flush() and entityManager.getTransaction().commit(), but when I look in the logs nothing seems to happen, even when the http session ends and the jdbc connection is released. I would normally expect to see hibernate issuing a sql update statement, but the update never seems to register. What strikes me as odd is that I have no problem creating new entities, this only seems to be effecting updates.
I am using a Singleton scoped servlet with an injected Provider<EntityManager>. Here is my persistence.xml: > <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_2_0.xsd" > > version="2.0"> > > <persistence-unit name="db-manager"> > > <provider>org.hibernate.ejb.HibernatePersistence</provider> > > <class>com.turms.server.database.DurableUser</class> > > <properties> > > <!-- Disable the second-level cache --> > > <property name="hibernate.cache.use_second_level_cache" >> value="false"/> > > >> <property name="hibernate.connection.driver_class" >> value="com.mysql.jdbc.Driver"/> > > <!--<property name="hibernate.connection.driver_class" >> value="org.apache.derby.jdbc.EmbeddedDriver"/>--> > > <property name="hibernate.connection.url" >> value="jdbc:mysql://localhost:3306/TestService"/> > > <property name="hibernate.connection.username" value="xxxxx"/> > > <property name="hibernate.connection.password" value="xxxxx"/> > > <property name="hibernate.connection.pool_size" value="1"/> > > <property name="hibernate.dialect" >> value="org.hibernate.dialect.MySQLDialect"/> > > <property name="hibernate.hbm2ddl.auto" value="create"/> > > <property name="hibernate.archive.autodetection" >> value="class"/> > > <property name="hibernate.show_sql" value="true"/> > > <!-- Default is false for backwards compatibility. Should be >> used on all new projects --> > > <property name="hibernate.id.new_generator_mappings" >> value="true"/> > > </properties> > > </persistence-unit> > > </persistence> > > Here is the code that is giving me problems: public boolean testUpdate(DurableUser user) { entityManager.get().getTransaction().begin(); String testUpdateString = "askdjfaskdjfalsdkf"; user.setField(testUpdateString); entityManager.get().persist(user); entityManager.get().flush(); entityManager.get().getTransaction().commit(); entityManager.get().clear(); return true; } In the logs from hibernate, org.hibernate.internal.util.EntityPrinter prints out the toString() of the updated entity (with the updated field set), but even with the flush() and commit() no update statement is issued. I'll be updating this post with more logs and environment information soon. -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/groups/opt_out.
