reset password
Author Message
Phobe
Posts: 40
Posted 15:47 Nov 23, 2010 |

I'm implementing the file copy method in FileDao. It is running in read-only mode though, so it is giving me errors. So question is, how to switch it to write mode? Any pointers?

Here's the relevant parts of the error:

2010-11-23 15:36:32,319 ERROR ExceptionResolver: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
2010-11-23 15:36:32,319 ERROR ExceptionResolver: org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

And snippets of the code:

public File copyFile( File file ) throws IOException
{
    File fileClone = new File(file);

    ...

    saveFile(fileClone);

    if (file.isFolder())
    {
        for (File f : listFiles(file))
        {
            File clone = copyFile(f);
            ...
            saveFile(clone);
        }
    }

    else
    {
        ...
    }

    return fileClone;
}

cysun
Posts: 2935
Posted 15:50 Nov 23, 2010 |

See the transactionAttributeSource bean definition in /conf/spring-data.xml.