cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ImpexImport - transaction rolled back because it has been marked as rollback-only

0 Kudos
962

I'm trying to import a bunch of data using the import service via code (testing in groovy via HAC for now), some records are duplicated (which is expected) hence all those duplications are marked as unresolved, the problem is that at the end, there is this error being thrown "transaction rolled back because it has been marked as rollback-only" and it rolls-back all data, including records that were processed successfully, so nothing gets imported in reality.

Interestingly, this is not happening if the data is imported directly from HAC->Impex Import section. I mean, the duplicated records are still failing, but successful records get imported correctly.

This is the Script:

import de.hybris.platform.servicelayer.impex.ImportConfig
import de.hybris.platform.servicelayer.impex.impl.StreamBasedImpExResource

def pathToFile = '/path/to/file.zip'

importFileData(pathToFile)

def importFileData(pathToFile) {
    def file = new File(pathToFile)
    def inputStream = new FileInputStream(file)

    //Prepares import config
    def config = new ImportConfig()
    config.setScript(new StreamBasedImpExResource(inputStream, 'UTF-8'))
    config.setValidationMode(ImportConfig.ValidationMode.RELAXED)
    config.setEnableCodeExecution(true)
    config.setLegacyMode(false)
    config.setFailOnError(false)

    //Executes export impex
    def importResult = importService.importData(config)

    println "   -> Finished importing zip file: ${file.name}"
    println "   -> Successful: ${importResult.isSuccessful()}"
    println '-----------------------------------------------------------------------------'
}

Have you come across this issue? Any clues on how to resolve this?

Accepted Solutions (0)

Answers (0)