Quantcast

Deleting not allowed in Tests?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Deleting not allowed in Tests?

Christian Laakmann
Hi everybody,

I get the following message in one of my integration-tests:

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.

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.
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1112)
at org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:793)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:791)
at org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:787)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:56)
at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:599)


Further down, the stack-trace points to a line, where I delete an object.

I tried to change the sessions's flush-mode to AUTO or COMMIT and althoug the flush-mode change, the error did not.

Has anybody encountered this before? Am I doing a mistake or should this not happen?

Greets
Christian
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

RE: Deleting not allowed in Tests?

Tim Pigden
I usually get this sort of thing when I've failed to save a created
object or I've saved without validating and it hasn't really saved it or
something like that

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Deleting not allowed in Tests?

pledbrook
In reply to this post by Christian Laakmann
> 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.
>
> 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.
> at

Also don't try to delete domain instances inside tearDown() - Grails
already handles this for you.

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Deleting not allowed in Tests?

Christian Laakmann
Thanks for your answers,

however I'm not trying to delete anything in tearDown and I am quite sure my domain-objects are valid.

Any other ideas?

Thanks
Christian

Peter Ledbrook wrote
> 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.
>
> 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.
> at

Also don't try to delete domain instances inside tearDown() - Grails
already handles this for you.

Cheers,

Peter

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Deleting not allowed in Tests?

Chris Chen
The error message is misleading.. usually you get this exception in  
integration because of the reasons that Tim Pigden stated.  It's  
almost always due to the failure to save or validate a domain object.

Make sure that you have provided values for all non-null fields, that  
they are pass validation, and that the field names are not mispelled.  
Those are normally the common causes for me.

If you want to quickly find the culprit, just remove all the domain-
related object creations and then add them back one at a time until  
you get the exception and you'll know which one is causing the problem.

Thanks,
Chris

On Dec 19, 2007, at 2:14 PM, Christian Laakmann wrote:

>
> Thanks for your answers,
>
> however I'm not trying to delete anything in tearDown and I am quite  
> sure my
> domain-objects are valid.
>
> Any other ideas?
>
> Thanks
> Christian
>
>
> Peter Ledbrook wrote:
>>
>>> 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.
>>>
>>> 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.
>>> at
>>
>> Also don't try to delete domain instances inside tearDown() - Grails
>> already handles this for you.
>>
>> Cheers,
>>
>> Peter
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Deleting-not-allowed-in-Tests--tp14425462p14426608.html
> Sent from the grails - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>    http://xircles.codehaus.org/manage_email
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Loading...