google-code-export / morphia

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

VersionMisuse (Validation) does not honor ObjectFactory #437

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I use a custom object factory to allow non-default args constructors (see 
http://www.jayway.com/2012/02/28/configure-morphia-to-work-without-a-default-con
structor/ ) as well as the Validation plugin.

This breaks once I add a @Version field to an entity, since VersionMisuse.java 
does not honor the specified custom object factory.  In fact, this is noted as 
a TODO in the code:

//TODO: Replace this will a read ObjectFactory call -- requires Mapper instance.
Object testInstance = DefaultCreator.createInst(mc.getClazz());

I'm filing a bug such that this issue is not forgotten (a trivial workaround is 
to provide a private non-arg constructor).

What version are you using? (Morphia/Driver/MongoDB)
0.99, but svn trunk version has the same error.

Please include a stack trace below:
...
Caused by: com.google.code.morphia.mapping.MappingException: No usable 
constructor for model.Picture
    at com.google.code.morphia.mapping.DefaultCreator.getNoArgsConstructor(DefaultCreator.java:142) [morphia-0.99.jar:]
    at com.google.code.morphia.mapping.DefaultCreator.createInst(DefaultCreator.java:117) [morphia-0.99.jar:]
    ... 177 more

Original issue reported on code.google.com by alex.big...@googlemail.com on 22 Oct 2012 at 8:21

GoogleCodeExporter commented 9 years ago
related: http://code.google.com/p/morphia/issues/detail?id=367#c6

Original comment by alex.big...@googlemail.com on 22 Oct 2012 at 8:52