jackson-datatype-hibernate
jackson-datatype-hibernate copied to clipboard
Allow passing `SessionFactory` override via (de)serialization attributes
(related to #58)
In addition to allowing module to be constructed with specific SessionFactory, it may be useful to allow passing of per-call factory instead. If so, this is easiest done using new "attributes" functionality that was added in Jackson 2.4.
Implementation should be quite easy with:
- Define key to use for the attribute: either custom
java.lang.Objectwith proper overrides (to guarantee equality-uniqueness) or just a String - Make
PersistentCollectionSerializeraware of key to use, check to see if aSessionFactoryhas been specified, use it.
and the only (?) messy part is the fact that the user needs to directly set given Attribute with the name; this can not be done via Module (since it's not connected with mapper after registration), although we could allow changing of key to use if that makes sense (not sure it does but whatever).