Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Multiple embedded objects not supported yet"? #28

Open
yuyou opened this issue Jul 28, 2011 · 11 comments
Open

"Multiple embedded objects not supported yet"? #28

yuyou opened this issue Jul 28, 2011 · 11 comments

Comments

@yuyou
Copy link

yuyou commented Jul 28, 2011

I saw following line in Model source code:
Logger.debug("multiple embedded objects not supported yet");

Could you plz elaborate it more? what does it exactly imply to the model design?

Thanks.

BRs,

Yu

@greenlaw110
Copy link
Collaborator

That only impact the case when you want to use Model.edit() method, e.g. load yml data file or edit current object using params coming from http form. You can still construct a complicated model structure if you use APIs.

@chrislambert
Copy link

This is something we need badly. We're not able to load MorphiaFixtures that contain lists of embedded documents, which happens in almost every one of our collections.

We may try to fix it this week if you think it's something simple. Right now, our workaround is to instantiate a bunch of embedded documents programmatically within setUp(). It's pretty ugly.

@greenlaw110
Copy link
Collaborator

Does JPA embedded object list supported now?

@chrislambert
Copy link

@bolinfest
Copy link

Unfortunately, I do not believe this is the case. I have been playing with
the code tonight, and I put together a pull request for Play that I believe
is required to support lists of @Embedded objects in PlayMorphia fixtures:

playframework/play1#433

Green, if you could provide any insight on this, it would be a big help.
With this change, I end up with instances of the @Embedded type in the
List, but none of the List's elements have its fields initialized (though
this is better than the NullPointerExceptions that were thrown previously).
Admittedly, much of the relevant classes that affect how fixtures are
instantiated (EmbeddedMapper, Mapper) are in Morphia rather than
PlayMorphia, but I'm guessing you are more familiar with them than I am.

On Mon, Jan 9, 2012 at 9:48 PM, chrislambert <
reply@reply.github.com

wrote:

Looks like it does in 1.2.4:

https://play.lighthouseapp.com/projects/57987/tickets/74-fixtures-should-support-assigning-an-embedded-object


Reply to this email directly or view it on GitHub:
#28 (comment)

@greenlaw110
Copy link
Collaborator

It's admitted that binding refactory work is not mature in play 1.2.4, and
Morphia is not be able to work well with this version. let's wait for 1.2.5
release and I will look back this issue then

On Tue, Jan 10, 2012 at 9:57 PM, bolinfest <
reply@reply.github.com

wrote:

Unfortunately, I do not believe this is the case. I have been playing with
the code tonight, and I put together a pull request for Play that I believe
is required to support lists of @Embedded objects in PlayMorphia fixtures:

playframework/play1#433

Green, if you could provide any insight on this, it would be a big help.
With this change, I end up with instances of the @Embedded type in the
List, but none of the List's elements have its fields initialized (though
this is better than the NullPointerExceptions that were thrown previously).
Admittedly, much of the relevant classes that affect how fixtures are
instantiated (EmbeddedMapper, Mapper) are in Morphia rather than
PlayMorphia, but I'm guessing you are more familiar with them than I am.

On Mon, Jan 9, 2012 at 9:48 PM, chrislambert <
reply@reply.github.com

wrote:

Looks like it does in 1.2.4:

https://play.lighthouseapp.com/projects/57987/tickets/74-fixtures-should-support-assigning-an-embedded-object


Reply to this email directly or view it on GitHub:

#28 (comment)


Reply to this email directly or view it on GitHub:
#28 (comment)

@bolinfest
Copy link

Well, unfortunately, we really need this functionality now, so I guess
we'll have to keep hacking the source ourselves :(

On Tue, Jan 10, 2012 at 4:15 AM, Green Luo <
reply@reply.github.com

wrote:

It's admitted that binding refactory work is not mature in play 1.2.4, and
Morphia is not be able to work well with this version. let's wait for 1.2.5
release and I will look back this issue then

On Tue, Jan 10, 2012 at 9:57 PM, bolinfest <
reply@reply.github.com

wrote:

Unfortunately, I do not believe this is the case. I have been playing
with
the code tonight, and I put together a pull request for Play that I
believe
is required to support lists of @Embedded objects in PlayMorphia
fixtures:

playframework/play1#433

Green, if you could provide any insight on this, it would be a big help.
With this change, I end up with instances of the @Embedded type in the
List, but none of the List's elements have its fields initialized (though
this is better than the NullPointerExceptions that were thrown
previously).
Admittedly, much of the relevant classes that affect how fixtures are
instantiated (EmbeddedMapper, Mapper) are in Morphia rather than
PlayMorphia, but I'm guessing you are more familiar with them than I am.

On Mon, Jan 9, 2012 at 9:48 PM, chrislambert <
reply@reply.github.com

wrote:

Looks like it does in 1.2.4:

https://play.lighthouseapp.com/projects/57987/tickets/74-fixtures-should-support-assigning-an-embedded-object


Reply to this email directly or view it on GitHub:

#28 (comment)


Reply to this email directly or view it on GitHub:

#28 (comment)


Reply to this email directly or view it on GitHub:
#28 (comment)

@zenoexo
Copy link

zenoexo commented Mar 12, 2012

Just as a side note, I found that a Gson Type binder that builds out an embedded object that can be saved with PlayMorphia. It goes something like this:

@Global
public class GsonBinder implements TypeBinder<JsonElement> {   
@Override    
public Object bind(String name, Annotation[] annotations, String value,  Class actualClass, Type genericType) throws Exception {        
return new JsonParser().parse(value); 
}}
/* controller */
public static void foo(JsonElement myEmbeddedJson){
  MyDeepEmbeddedClass bar = new Gson().fromJson(myEmbeddedJson, MyDeepEmbeddedClass.class);
  bar.save();
}

If you are dealing with JSON data to begin with this approach can work - if not, won't help.

@greenlaw110
Copy link
Collaborator

Hello since v1.2.7 now is using play 1.2.4 binding mechanism, can anyone of you check if this issue get fixed on 1.2.7+ ?

@shoon
Copy link

shoon commented Jun 30, 2012

Edit - Sorry, I wasn't using MorphiaFixtures

As of 1.2.9a I am unable to load in a yaml file that has list of referenced objects. Exception:

com.google.code.morphia.mapping.MappingException: Error mapping field:....
at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:448)
at com.google.code.morphia.mapping.Mapper.toDBObject(Mapper.java:430)
at com.google.code.morphia.DatastoreImpl.entityToDBObj(DatastoreImpl.java:707)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:755)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:826)
at com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:820)
at play.modules.morphia.Model.save2(Model.java:729)
at play.modules.morphia.Model.save(Model.java:716)
at play.modules.morphia.Model._save(Model.java:59)
at play.test.Fixtures.loadModels(Fixtures.java:221)
....

@eaorak
Copy link

eaorak commented Dec 4, 2013

Are there any updates regarding this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants