persistence@glassfish.java.net

Re: Trting to add new child entity; getting OptimisticLockException

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Wed, 27 Sep 2006 15:28:36 -0700

Hi Gustavo,

sounds like a bug to me. Please prepare a test case and file a glassfish
issue under

http://glassfish.dev.java.net

Thanks,

-- markus
gdurand_at_hmdc.harvard.edu wrote:

> Hi,
>
> I'm am trying a very simple example and am getting a problem
> (I am using glassfish v2 milestone 1):
>
> Our DB has a Study entity which has a one to many relationship
> with a FileCategory entity.
>
> When I try to add a FileCategory to an existing study:
>
> Collection categories = study.getFileCategories();
>
> FileCategory c = new FileCategory();
> c.setName( "test" );
>
>
> c.setStudy(study);
> categories.add(c);
>
> em.merge(study);
>
> I am getting:
>
> Exception Details:
> oracle.toplink.essentials.exceptions.OptimisticLockException
> Exception Description: The object
> [edu.harvard.hmdc.vdcnet.study.FileCategory_at_1f1c748] cannot be merged
> because it has changed or been deleted since it was last read.
> {3}Class> edu.harvard.hmdc.vdcnet.study.FileCategory
>
>
>
> Any ideas why this is happening, since the FileCategory doesn't exist
> in the first place? (I have seen an example in the O'Reilly book that
> pretty much does just this)?
>
> Thanks,
> Gustavo
>
>
>