hibernate - Atomikos rollback doesn't clear JPA persistence context? -


I have a Spring / JPA / Hibernate application and I pass it on to my junior integration tests against H2 and MySQL I am trying to Currently I am using Atomicos for transaction pooling and C3P for connection pooling.

Despite one of my best efforts, one of my DAO integration tests has failed with org.hibernate.NonUniqueObjectException. In the unsuccessful test, let me create an object with the "new" operator, set the id on it and continue the call on it.

  @Test @transpublic public save_UserTestDataNewObject_RecordSetOneLarger () {int Expected number number = 4; User newUser = createNewUser (); Dao.persist (NEWUSER); & Lt; Users & gt; AllUsers = dao.findAll (0, 1000); AssertEquals (expected digits, allUsers.size ()); }  

In the last testmethod, I create the same thing (createNewUser () is a helpful method that creates an object with the same ID). I am convinced that there is a reason to create and maintain a second object with the same ID, but each exam method is in its own transaction and the object that I created is connected to the personal test method variables. I can also see in log that Spring Test and Etimos are bringing back the transaction associated with each exam system.

I must have thought that Rollback must have ratified reference too. On a hip, I added a call to dao.clear () at the beginning of the faulty test method and the problem went away !! So the rollback persistence does not explain the context ??? If not, who does it ??

My entity manager manager is as follows:

  Bean id = "myappTestLocalEmf" class = "org.springframework.orm.jpa .LocalContainerEntityManagerFactoryBean" & gt; & Lt; Property name = "firmness unitname" value = "myapp-core" /> & Lt; Property Name = "Persistent Unit Post Processors" & gt; & Lt; Bean class = "com.myapp.core.persist.util.JtaPersistenceUnitPostProcessor" & gt; & Lt; Property Name = "jtaDataSource" Riff = "myappPersistTestJdbcDataSource" /> & Lt; / Bean & gt; & Lt; / Property & gt; & Lt; Property Name = "JPAVENDER Adapter" & gt; & Lt; Bean square = "org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" & gt; & Lt; Property Name = "Show SQL" value = "true" /> & Lt; Property name = "database" value = "$ DS {hibernate.database}" /> & Lt; Property Name = "Database Platform" Value = "$ DS {hibernate.dialect}" /> & Lt; / Bean & gt; & Lt; / Property & gt; & Lt; Property Name = "JPAP Properties" & gt; & Lt; Theater Content & gt; & Lt; Prop key = "hibernate.transaction.factory_class" & gt; Com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory & lt; / Prop & gt; & Lt; Prop key = "hibernate.transaction.manager_lookup_class" & gt; Com.atomikos.icatch.jta.hibernate3.TransactionManager Lookup & lt; / Prop & gt; & Lt; Prop key = "hibernate.connection.autocommit" & gt; False & lt; / Prop & gt; & Lt; Prop key = "hibernate.format_sql" & gt; True " & lt; key = prop" hibernate.use_sql_comments "> true   gt; bean & gt; ;  From the JPA specification: 

3.3.

It's weird. 2 Transactions Rollback

For both transaction-scoped and extended persistent references, transaction rollback managed and deleted all pre-existing instances Examples are different. Examples' The state will be the examples at which point of The transaction was rolled back to the state that the transaction rollback usually causes persistence to be in an incompatible position at the point of reference rollback. Specifically, the version features state and generated state (e.g., primary Generated key) may be inconsistent. (The example with a new example is that it is managed by persistence context in the past that the deal is continuously) so that other different objects - examples For, when they merged were passed to the operation could be as be reusable in the same manner failed.

The way I read above, the above section is that when the transaction is brought back, then the JPA should clean its references.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -