BlackLabs / play-morphia

Provide mongodb access service to play.db.Model via Morphia
Apache License 2.0
130 stars 49 forks source link

Save binding issue in CRUD module 1.2.4 with Morphia 1.2.9 #90

Closed pelayuko closed 12 years ago

pelayuko commented 12 years ago

I have a sample app in play 1.2.4 with CRUD module enabled and Morphia 1.2.9, when I try to save an entity params are not binded so modified object is not persisted.

greenlaw110 commented 12 years ago

Without your code I can hardly understand where the root cause is.

On Sat, Jun 30, 2012 at 5:38 AM, yukogfu < reply@reply.github.com

wrote:

I have a sample app in play 1.2.4 with CRUD module enabled and Morphia 1.2.9, when I try to save an entity params are not binded so modified object is not persisted.


Reply to this email directly or view it on GitHub: https://github.com/greenlaw110/play-morphia/issues/90

pelayuko commented 12 years ago

Sorry, is the code provided by CRUD module. Anyway I've also tryied with yabe sample provided in samples folder of play-morphia project with morphia 1.2.9 as dep and running over play 1.2.4.

I have override save method of CRUD controller to trace:

``` ObjectType type = ObjectType.get(getControllerClass()); notFoundIfNull(type); Model object = type.findById(id); notFoundIfNull(object); Logger.debug("before bind object" + object); Binder.bindBean(params.getRootParamNode(), "object", object); Logger.debug("after bind object" + object); ``` Thx
pelayuko commented 12 years ago

I'va finally found the solution -maybe a workaround- , override method bindBean(..) of PlayPlugin in MorphiaPlugin as:

``` @Override public Object bindBean(RootParamNode rootParamNode, String name, Object bean) { if (bean instanceof Model) { return Model.edit(rootParamNode, name, bean, null); } return null; } ```
pelayuko commented 12 years ago

solved in play 1.2.5