google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

error using datastore with composite _id #307

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a class with another class as an _id field.
when doing save/insert via the BasicDAO, i get the following exception.
doing save insert via the collection itself works just fine.

What version are you using? (Morphia/Driver/MongoDB)
mongo 2.5 and morphia 1.0 snapshit
Please include a stack trace below:

java.lang.RuntimeException: @Id mismatch: 
knil.categories.mongo.beans.ObjectClassType$CTId@190872ce != 
knil.categories.mongo.beans.ObjectClassType$CTId@5675b3ee for 
knil.categories.mongo.beans.ObjectClassType
        at com.google.code.morphia.mapping.Mapper.updateKeyInfo(Mapper.java:239)
        at com.google.code.morphia.DatastoreImpl.postSaveOperations(DatastoreImpl.java:933)
        at com.google.code.morphia.DatastoreImpl.postSaveGetKey(DatastoreImpl.java:716)
        at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:767)

Original issue reported on code.google.com by had...@gmail.com on 5 Aug 2011 at 8:32

GoogleCodeExporter commented 9 years ago
Can you provide a sample of code to reproduce this?

Original comment by scotthernandez on 5 Aug 2011 at 1:24

GoogleCodeExporter commented 9 years ago
@Embeded
public class Oid
{
 public Long x;
 public Long y;

public oID(Long x,Long y)
{
this.x = x;
this.y = y;
}
}

@Entity
public class Ent
{
  @Id
  Oid id;
  public ent(Oid id)
{
  this.id = id;
}
}
Morphia morphia = new Morphia().map(Ent.class)
new DatastoreImpl(morphia,mongo).insert(new Ent(new Oid(1l,2l)));

the object is saved just fine, but the above exception is thrown

Original comment by had...@gmail.com on 18 Jan 2012 at 10:21

GoogleCodeExporter commented 9 years ago
the last line where the datastore creation is should be.
morphia.createDatastore(mongo,"test").save(new Ent....;

Original comment by had...@gmail.com on 18 Jan 2012 at 10:32

GoogleCodeExporter commented 9 years ago
Issue 378 has been merged into this issue.

Original comment by scotthernandez on 23 Feb 2012 at 6:00

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r1809.

Original comment by scotthernandez on 23 Feb 2012 at 6:01

GoogleCodeExporter commented 9 years ago

Original comment by scotthernandez on 23 Feb 2012 at 6:09