You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of now, Morphia scans entity classes for "interesting annotations". Once it finds a field with an "interesting annotation" it puts it into "persistence fields". Once I apply "ensureIndexes" to datastore all of the persistence fields classes that hasn't been copied into "mapped classes" is copied into that collection.
Then, when mapping happens, Morphia checks if a field class is member of that collection and doesn't apply converters if it is.
Is there any particular reason for that? Can it be changed that Morphia applies converters for mapped classes also? It would be really neat to be able to customise how model objects are built from DBObjects for certain cases.
My use case is that I have immutable class with private constructor as part of api and I want to be able to store and retrieve objects of that class with Mongodb. While I am able to store it - I'm unable to load it as Morphia's default behaviour is to use default constructor and I don't have one.
I was able to override ObjectFactory with my custom class but it only controls the object instantiation phase, Morphia still writes values into my private final fields which I would like to avoid using converters.
The text was updated successfully, but these errors were encountered:
Updating the mapping code in 1.x to do constructor injection of values would an enormous amount of work, I think. The mapping code in 2.x has been rewritten and is much more suitable for such an addition and is, in fact, on the roadmap albeit by a very old bug (#581).
I know this answer is less than ideal but it's why I worked so hard to refactor all that for 2.0.
As of now, Morphia scans entity classes for "interesting annotations". Once it finds a field with an "interesting annotation" it puts it into "persistence fields". Once I apply "ensureIndexes" to datastore all of the persistence fields classes that hasn't been copied into "mapped classes" is copied into that collection.
Then, when mapping happens, Morphia checks if a field class is member of that collection and doesn't apply converters if it is.
Is there any particular reason for that? Can it be changed that Morphia applies converters for mapped classes also? It would be really neat to be able to customise how model objects are built from DBObjects for certain cases.
My use case is that I have immutable class with private constructor as part of api and I want to be able to store and retrieve objects of that class with Mongodb. While I am able to store it - I'm unable to load it as Morphia's default behaviour is to use default constructor and I don't have one.
I was able to override ObjectFactory with my custom class but it only controls the object instantiation phase, Morphia still writes values into my private final fields which I would like to avoid using converters.
The text was updated successfully, but these errors were encountered: