-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: 'Any' type mappings problem
PostPosted: Thu Oct 20, 2005 8:51 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
I've got a small problem, but I'm not sure whether it's a bug or behavior by design:

When I use <any> type mappings in a class to represent a relationship with any other type of class I get the following exception when trying to load a persisted class with an <any> reference after my framework has been recompiled:

Code:
FileLoadException
The located assembly's manifest definition with name 'Framework.Core' does not match the assembly reference.
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at NHibernate.Util.ReflectHelper.ClassForName(String name)
   at NHibernate.Type.TypeType.Get(IDataReader rs, Int32 index)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
   at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name, ISessionImplementor session, Object owner)
   at NHibernate.Type.ObjectType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
   at NHibernate.Loader.Loader.Hydrate(IDataReader rs, Object id, Object obj, ILoadable persister, ISessionImplementor session, String[][] suffixedPropertyColumns)
   at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, Key key, String suffix, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
   at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, String suffix, Key key, LockMode lockMode, Key optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
   at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, String[] suffixes, Key[] keys, Object optionalObject, Key optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
   at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
   at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
   at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
   at NHibernate.Hql.QueryTranslator.List(ISessionImplementor session, QueryParameters queryParameters)
   at NHibernate.Impl.SessionImpl.Find(String query, QueryParameters parameters)


I guessing that this is being caused by the fact that the <any> entity class's name is being persisted like this...

Code:
Framework.Core.Entities.DeliveryJob, Framework.Core, Version=1.0.2119.16496, Culture=neutral, PublicKeyToken=ce0a415fb14adce2


..and after recompilation the Version value is updated to a new value which no longer matches.

Is this by design or a bug? If it's by design then what's the workaround? I don't want to have this error thrown for pre-existing data just because I recompile for a bug fix!

Hope someone out there can help...

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 10:20 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can define your own strings for various types using <meta-value> tag, see http://www.hibernate.org/hib_docs/reference/en/html/mapping.html, section 5.2.5.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 10:35 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Thanks sergey,

I saw that, but I'm not entirely clear on how it works. Is it that when you pass in a class of a specified type that it writes the meta data value as the discriminator in the table then on load it reads the discriminator from the table to establish the type? What happens when a type that's not in the meta data list is submitted?

I guess your answer also means that using the class (default) implementation is not really useful if you recompile. Is that because GetType requires a fully qualified class name string (including the assembly and it's related information) to find a class that's not in the current (NHibernate) assembly? Otherwise I'd wonder why the type's FullName and basic assembly name isn't used instead...

Thanks for replying so fast and cheers for your help!

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 10:42 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Actually, after a little experimentation where I manually edited the DB entries to remove the additional assembly information I discovered that it works just fine:

The value that was originally persisted for the <any> type...

Code:
Framework.Core.Entities.DeliveryJob, Framework.Core, Version=1.0.2119.16496, Culture=neutral, PublicKeyToken=ce0a415fb14adce2


...which I editited to...

Code:
Framework.Core.Entities.DeliveryJob, Framework.Core


...loads just fine.

Perhaps this should be updated in the NH codebase so that <any> type mappings without meta data can be persisted and re-loaded after a compile? Or is that just silly?

Cheers,

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.