Support <any> with meta-type="class"
Description
Environment
Activity

Fabio Maulo July 24, 2008 at 4:22 PM
Now?
No, take a look to the "Fix version"... it is 2.0.0RC1

scott fluto July 24, 2008 at 1:27 PM
Is there any problem with my <any> mapping then for nhibernate 2.0?

Fabio Maulo July 23, 2008 at 8:41 AM
The breaking change are:
default meta-type is "string" (no more "class")
when meta-type="class" the persistent type is a string containing the entity-name (persistentClass.FullName).
to set a parameter in a query you must use
SetParameter("paraName", typeof(YourClass).FullName, NHibernateUtil.ClassMetaType)
H3.2 don't support meta-type="class" so, now, it is a specific NH feature.
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-types-anymapping

Fabio Maulo July 23, 2008 at 7:23 AM
Wait, wait....
I'm working on it to support meta-type="class" because it is important when you have a plugable app and you don't know which will be the entities in the association.
The only one breaking change will be that now the default for meta-type will be "string" so you must specify meta-type="class".
If the meta-type != "class" you must specify meta-value too.
meta-type="class" we will support entity-name that mean that the persisted string will be the entity-name or class-fullname.

scott fluto July 23, 2008 at 5:58 AM
Given that , how would I change my mapping to get the same functionality I had in this <and> mapping using the meta-type option.
Also , is there documentation yet on all the changes and the deprecated functionality.
Details
Details
Assignee

Reporter

I was trying to port our app to Nhibernate 2.0 using the current beta2 and I found that it fails for certain things related to the <any> mapping attribute
this is the mapping in my class mapping a child class that is actually an interface so I have to use <any> mapping type:
<any name="Original" meta-type="class" id-type="Guid" cascade="all">
<column name="ORIGINAL_CLASS"/>
<column name="ORIGINAL_ID"/>
</any>
-when its trying to put fully qualified class name into the original_class field it needs to get the fully qualified name to put in it so it calls SessionImpl.BestGuessEntityName
-this method ends up returning Oas.ChildObject . Note its just the class name and not the fully assembly qualified name.
it then calls TypeType.Set. this method gets this string passed into it: "Oas.ChildObject"
public override void Set(IDbCommand cmd, object value, int index)
{
NHibernateUtil.String.Set(cmd, ((System.Type)value).FullName, index);
}
-it fails on the cast since its not a fully assembly qualified name in the passed in string and it cant cast to a System.Type so I get a casting error. Everything works with nhibernate 1.2 so it looks like something in 2.0 . I havnt given a good working example but I hope this help anyhow so if anyone could shed any light on this I would be grateful.
thanks
scott