Hi everyone,

I'm trying to test a method that uses JDO and I can't figure out where
the problem is. I get this exception when I execute a test method.

org.datanucleus.exceptions.NucleusUserException: Object with id "" is
managed by a different ObjectManager
        at
org.datanucleus.ObjectManagerImpl.findStateManager(ObjectManagerImpl.java:
756)

        @Test
        public void nuevaEntidadMismoNombreTest(){

                Entidad entidad = new Entidad(nombre, cif, tipo, localizacion);
                Entidad entidad2 = new Entidad(nombre, cif, tipo, localizacion);

                Entidad nuevaEntidad = entidadDao.crearEntidad(entidad);
                Entidad nuevaEntidad2 = entidadDao.crearEntidad(entidad2);

        }

The method that I use to create the Entity is.

public Entidad crearEntidad(Entidad entidad) {
                PersistenceManager pm = PMF.get().getPersistenceManager();
                try{
                        Entidad nuevaEntidad = pm.makePersistent(entidad);
                        return  pm.detachCopy(nuevaEntidad);
                }finally{
                        pm.close();
                }
        }

For getting the PM I used the class recommended by Google

public final class PMF {
    private static final PersistenceManagerFactory pmfInstance =
        JDOHelper.getPersistenceManagerFactory("transactions-
optional");

    private PMF() {}

    public static PersistenceManagerFactory get() {
        return pmfInstance;
    }
}

I've also added the setting up of the datastore folowing the Google's
documentation instructions.

private final LocalServiceTestHelper dataHelper = new
LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());

Can anyone tell my why I'm getting this exception?

Thanks in advance.

Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to