What is Tuplizer at NHibernate

I came across a post mentioning Tuplizer on NHibernate, can anyone provide a good definition or link for Tuplizer?

+7
nhibernate tuplizer
source share
3 answers

From ITuplizer Source Code :

The terminator defines a contract for things that know how to manage a particular representation of a piece of data, given that the EntityMode view (entity-mode is basically a view).

If this piece of data is considered as data structures, then tuplizer is what it knows, as in:

  • create such a data structure appropriately
  • extract values ​​from and enter values ​​into such data

For example, a given piece of data may be represented as a POCO class. Here is the view and entity-mode is POCO. Well, the deadlock for POCO entity modes would be known, as in:

  • create a data structure call POCO constructor
  • retrieve and enter values ​​via getters / setter, or direct access field, etc.

The same piece of data can also be represented as DOM structures, using a dead end associated with an XML entity that will generate XmlElement instances as a data structure and know how to access values ​​as either nested XmlElements or XmlAttributes.

In the words of Fabio Molo :

Tuplizer defines how to transform a property-value into its constant representation, and vice versa - the value of a column-value for its representation in memory, and EntityMode determines which tuplizer is used.

Some things you can do with custom tuplizers:

+6
source share

Well, this can help to understand what a tuple is, firstly:

http://en.wikipedia.org/wiki/Tuple

Python is most notable for having first-class support for Tuples, although some other languages ​​also do (F #)

http://diveintopython3.ep.io/native-datatypes.html#tuples

and of course!

https://stackoverflow.com/search?q=tuples

+1
source share

org.hibernate.tuple.Tuplizer and its sub-interfaces are responsible for managing the specific view of the data part, given that the view is org.hibernate.EntityMode . If a given piece of data is considered as a data structure, then tuplizer is what knows how to create such a data structure and how to extract values ​​from and enter values ​​into such a data structure. For example, for POJO entity mode, the corresponding tuplizer knows how to create a POJO through its constructor. He also knows how to access POJO properties using specific property attributes. There are two types of high-level Tuplizers provided by org.hibernate.tuple.entity.EntityTuplizer and org.hibernate.tuple.component.ComponentTuplizer . EntityTuplizers are responsible for managing the aforementioned contracts with respect to organizations, while ComponentTuplizers do the same for components.

0
source share

All Articles