Skip to content

Update the <any /> mapping documentation #1809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2018

Conversation

fredericDelaporte
Copy link
Member

This documentation is obsolete since NH 2.0.

This documentation is obsolete since NH 2.0.
<programlisting><![CDATA[<any name="AnyEntity" id-type="Int64" meta-type="Eg.Custom.Class2TablenameType">
<column name="table_name"/>
<programlisting><![CDATA[<any name="AnyEntity" id-type="long" meta-type="class">
<column name="type"/>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have to be a table name.

<literal>id-type</literal>. If the meta-type returns instances of <literal>System.Type</literal>,
nothing else is required. On the other hand, if it is a basic type like <literal>String</literal> or
<literal>Char</literal>, you must specify the mapping from values to classes.
<literal>id-type</literal>. If the meta-type is <literal>class</literal>, nothing else is required.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support of TypeType is gone since NH 2.0, as reported in NH-1403. This has been fixed by "hijacking" the TypeType alias class for instead yielding ClassMetaType when class is used in the meta-type attribute of an any mapping (or ...-to-any).
(This can be confusing for those who know class is TypeType alias, because TypeType persists the assembly qualified type name whereas ClassMetaType persists the full-name instead (no assembly in it).)

<literal>id-type</literal>. If the meta-type is <literal>class</literal>, nothing else is required.
The class full name will be persisted in the database as the type of the associated entity.
On the other hand, if it is a basic type like <literal>string</literal> or
<literal>char</literal>, you must specify the mapping from values to classes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not actually true: string and any string like types may work without meta-values. In such case they work somewhat similarly to class, but without a dedicated NHibernate MetaType. That causes issues, like those not fixed in #1803. So I have decide to keep that sentence.

If we fix this, this part would have to be updated.

@hazzik hazzik changed the title Update the any mapping documentation Update the <any /> mapping documentation Jul 18, 2018
@hazzik hazzik merged commit 3f0df4a into nhibernate:master Jul 19, 2018
@fredericDelaporte fredericDelaporte deleted the anyDoc branch July 19, 2018 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants