0

I was fetch records from .csv file using smooks the size of file is around 30MB data in single file ,in this file around 3 laks of records fetch into List..

i was done next List is divided into subparts using subList Partition size is upto 2000 .

i want to flush 2000 records in single transaction .but it not allow like that in my code.

I am using seam 2.1.2 ,jap with hibernate ,EntityManager ,JTA Transactions.

components.xml

  <core:init debug="false" jndi-pattern="@jndiPattern@" />
    <core:manager concurrent-request-timeout="2000"
        conversation-id-parameter="cid" conversation-timeout="120000"
        parent-conversation-id-parameter="pid" />
    <web:hot-deploy-filter url-pattern="/*.mobee" />
    <persistence:entity-manager-factory
        installed="@seamBootstrapsPu@" name="entityManagerFactory"
        persistence-unit-name="mobeeadmin" />
    <persistence:managed-persistence-context 
        auto-create="true" entity-manager-factory="@seamEmfRef@" name="entityManager"
        persistence-unit-jndi-name="@puJndiName@" />
 <async:quartz-dispatcher />
    <security:identity authenticate-method="#{authenticator.authenticate}" />
  <web:rewrite-filter view-mapping="*.mobee" />
    <web:multipart-filter create-temp-files="true" max-request-size="28672000"     url-pattern="*.seam"/>
    <event type="org.jboss.seam.security.notLoggedIn">
        <action execute="#{redirect.captureCurrentView}" />
    </event>
<event type="org.jboss.seam.security.loginSuccessful">
        <action execute="#{redirect.returnToCapturedView}" />
    </event>
    <mail:mail-session host="localhost" port="25" />

Java Code:

  private  List<DoTempCustomers> doTempCustomers;

   int partitionSize = 2000;

   for (int i = 0; i < doTempCustomers.size(); i += partitionSize) {
      String message= tempCustomerMigration(doTempCustomers.subList(i,
               i + Math.min(partitionSize, doTempCustomers.size() - i)));
   }



 @Begin(join=true)
    public String tempCustomerMigration(List<DoTempCustomers>  list){
         PersistenceProvider.instance().setFlushModeManual(getEntityManager());
         TempCustomers temp = null;
      for(DoTempCustomers tempCustomers:list){
        try {
        temp=new TempCustomers();
            BeanUtils.copyProperties(temp, tempCustomers);
            getEntityManager.persist();
            getEntityManager.flush();
         }

i was tried so many times this issue never got sol on how to flush record to DB in each transaction before send server response to GUI

otherwise some process time i got exception is

2012-12-06 17:09:56,380 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id -53eff40e:f2db:50c0a356:7d invoked while multiple threads active within it.
2012-12-06 17:09:56,380 WARN  [com.arjuna.ats.arjuna.logging.arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action -53eff40e:f2db:50c0a356:7d aborting with 1 threads active!
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.parentTraceEnabled=true
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.nestedTraceEnabled=false
2012-12-06 17:09:56,522 DEBUG [org.jboss.util.NestedThrowable] org.jboss.util.NestedThrowable.detectDuplicateNesting=true
2012-12-06 17:09:56,524 INFO  [STDOUT] [Mobee]- WARN 2012-12-06 17:09:56,524 [] JDBCExceptionReporter - SQL Error: 0, SQLState: null
2012-12-06 17:09:56,525 INFO  [STDOUT] [Mobee]-ERROR 2012-12-06 17:09:56,524 [] JDBCExceptionReporter - Transaction is not active: tx=TransactionImple < ac, BasicAction: -53eff40e:f2db:50c0a356:7d status: ActionStatus.ABORTING >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -53eff40e:f2db:50c0a356:7d status: ActionStatus.ABORTING >)
2012-12-06 17:09:56,545 INFO  [STDOUT] [Mobee]-ERROR 2012-12-06 17:09:56,527 [] AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)

for this exception i found sol in google for increase to TransactionTimeout in jboss--service.xml for me there is no use even increasing timeout parameter.

nag
  • 647
  • 6
  • 25
  • 43

1 Answers1

0

You could create a new Seam component that is an EJB Session Bean and use a UserTransaction to perform your updates/inserts in batches. UserTransaction also lets you specify the transaction timeout. You would inject this new component into the component that you're using above. Here is an example - see the 5th post.. Otherwise, if you don't want to use an EJB, I think your approach would require you to use a nested Seam conversation since it appears that you are using a Seam managed persistence context that is scoped to a single conversation.

S Balough
  • 183
  • 4