|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-24 14:19:43
|
[ http://216.121.112.228/browse/NH-2569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo resolved NH-2569.
-----------------------------
Resolution: Fixed
Fix Version/s: 3.2.0Alpha3
> IDGeneratorBinding seems broken when mixing schemas
> ---------------------------------------------------
>
> Key: NH-2569
> URL: http://216.121.112.228/browse/NH-2569
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.0.0.GA
> Reporter: Ciaran Jessup
> Priority: Minor
> Fix For: 3.2.0Alpha3
>
> Attachments: OverWriteSchemaInIdGenerator.patch
>
>
> We seem to have run into an issue when using the NHibernate.Id.TableHiLoGenerator over a table in a db schema different to the schema that the containing table/class belongs to.
> A mapping similar to:
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly" namespace="MyNamespace">
> <class name="MyAssembly.MyAwesomeRecord, MyAssembly" table="MyAwesomeRecords" schema="Foo">
> <id name="Id" column="mar_id" type="Int64" unsaved-value="-1">
> <generator class="NHibernate.Id.TableHiLoGenerator">
> <param name="table">hilosequences</param>
> <param name="column">sequence_next_hi_value</param>
> <param name="where">sequence_name='MyAwesomeRecord'</param>
> <param name="max_lo">1</param>
> <param name="schema">Bar</param>
> </generator>
> </id>
> </class>
> </hibernate-mapping>
> (Note the two schemas, Foo on the enclosing class, and Bar on he IDGenerator's underlying table)
> If included in your hibernate mappings will cause hibernate to fail to start with an exception along the lines of :
> 2011-03-10 11:04:19,777 [9] ERROR NHibernate.Cfg.Configuration [(null)] <(null)> - Could not compile the mapping document: Numero.SmartAgent.Workflow.Maps.WorkItem.hbm.xml
> NHibernate.MappingException: Could not compile the mapping document: MyAssembly.MyAwesomeRecord.hbm.xml ---> System.ArgumentException: An item with the same key has already been added.
> at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
> at NHibernate.Cfg.XmlHbmBinding.IdGeneratorBinder.GetGeneratorProperties(HbmGenerator generatorMapping, String schema)
> at NHibernate.Cfg.XmlHbmBinding.IdGeneratorBinder.BindGenerator(SimpleValue id, HbmGenerator generatorMapping)
> at NHibernate.Cfg.XmlHbmBinding.ClassIdBinder.BindId(HbmId idSchema, PersistentClass rootClass, Table table)
> at NHibernate.Cfg.XmlHbmBinding.RootClassBinder.Bind(HbmClass classSchema, IDictionary`2 inheritedMetas)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.AddEntitiesMappings(HbmMapping mappingSchema, IDictionary`2 inheritedMetas)
> at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(HbmMapping mappingSchema)
> at NHibernate.Cfg.Configuration.AddDeserializedMapping(HbmMapping mappingDocument, String documentFileName)
> --- End of inner exception stack trace --
> I believe this is caused by the IdGeneratorBinder#GetGeneratorProperties preferentially using the schema of the containing table/class and then trying to add the id generator's configured schema to the underlying collection after the table one has already been added.
> I've supplied a trivial patch that I believe 'fixes' it for me, but it is most likely not the correct fix that someone else would want :)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|