Provide cacheable representations for all NHibernate built-in types #1765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As written in nhibernate/NHibernate-Caches#45, some NHibernate built-in types do not have a proper cacheable representation. Many cache providers relies on cached objects being binary serializable (even some non-distributed ones), but some NHibernate types yields representations which are not, or which convey way more information than actually handled by NHibernate.
Moreover if the type can be a simple type, easing support of other kind of serializations (Json), that is better.
CultureInfoType
yields a fullCultureInfo
object, while it only persists itsName
.TypeType
yields aSystem.Type
object, which is not binary serializable under .Net Core.UriType
yields anUri
object, while it only persists the uri.XDocType
yields aXDocument
which is not binary serializable.XmlDocType
yields aXmlDocument
which is not binary serializable.These five types are all persisted as string in the database, so they already naturally have a cacheable representation. This PR uses that string representation.
Additionally better guidance has been added on
IUserType
Assemble
/Disassemble
methods.This is a possible breaking change, because any out-of-process second level cache would have to be cleared after upgrading NHibernate, if some of those types were cached.