Stackoverflow link if anybody wants the bounty: 
http://stackoverflow.com/questions/20390497/update-to-entity-is-not-recognized-or-persisted-when-using-guice-persist

Here are the logs from the session:

2013-12-04 20:56:10,881 DEBUG http-apr-8080-exec-7    
spi.AbstractTransactionImpl - begin
2013-12-04 20:56:10,881 DEBUG http-apr-8080-exec-7           
jdbc.JdbcTransaction - initial autocommit status: true
2013-12-04 20:56:10,881 DEBUG http-apr-8080-exec-7           
jdbc.JdbcTransaction - disabling autocommit
2013-12-04 20:56:10,881  INFO http-apr-8080-exec-7                    
dao.UserDao -  user field persisted
2013-12-04 20:56:10,881 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Processing flush-time cascades
2013-12-04 20:56:10,881 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Dirty checking collections
2013-12-04 20:56:10,882 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.cards#7], was: 
[com.xxx.server.database.DurableUser.cards#7] (initialized)
2013-12-04 20:56:10,882 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.donations#7], was: 
[com.xxx.server.database.DurableUser.donations#7] (initialized)
2013-12-04 20:56:10,882 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.installments#7], was: 
[com.xxx.server.database.DurableUser.installments#7] (initialized)
2013-12-04 20:56:10,882 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions 
to 1 objects
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 
removals to 3 collections
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7             
util.EntityPrinter - Listing entities:
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7             
util.EntityPrinter - com.xxx.server.database.DurableUser{donations=[], 
installments=[], id=7, username=test, name=test testerson, 
passwordChangeKey=askdjfaskdjfalsdkf, cards=[]}
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7    
spi.AbstractTransactionImpl - committing
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Processing flush-time cascades
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Dirty checking collections
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.cards#7], was: 
[com.xxx.server.database.DurableUser.cards#7] (initialized)
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.donations#7], was: 
[com.xxx.server.database.DurableUser.donations#7] (initialized)
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7           
internal.Collections - Collection found: 
[com.xxx.server.database.DurableUser.installments#7], was: 
[com.xxx.server.database.DurableUser.installments#7] (initialized)
2013-12-04 20:56:10,883 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions 
to 1 objects
2013-12-04 20:56:10,884 DEBUG http-apr-8080-exec-7 
.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 
removals to 3 collections
2013-12-04 20:56:10,884 DEBUG http-apr-8080-exec-7             
util.EntityPrinter - Listing entities:
2013-12-04 20:56:10,886 DEBUG http-apr-8080-exec-7             
util.EntityPrinter - com.xxx.server.database.DurableUser{donations=[], 
installments=[], id=7, username=test, name=test testerson, 
passwordChangeKey=askdjfaskdjfalsdkf, cards=[]}
2013-12-04 20:56:10,886 DEBUG http-apr-8080-exec-7           
jdbc.JdbcTransaction - committed JDBC Connection
2013-12-04 20:56:10,886 DEBUG http-apr-8080-exec-7           
jdbc.JdbcTransaction - re-enabling autocommit
2013-12-04 20:56:11,613 DEBUG http-apr-8080-exec-7 
internal.LogicalConnectionImpl - Releasing JDBC connection
2013-12-04 20:56:11,614 DEBUG http-apr-8080-exec-7 
internal.LogicalConnectionImpl - Released JDBC connection

On Wednesday, December 4, 2013 7:40:18 PM UTC-6, lrmills12 wrote:
>
> 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.

Reply via email to