Hello all,
namespace
NHibernate.Mapping
{
...
public
class Table
: IRelationalModel
{
...
public
string UniqueColumnString(IEnumerable iterator, string
referencedEntityName)
{
...
return (name.GetHashCode().ToString("X") + result.GetHashCode().ToString("X")); // Ouch!
}
}
}
We’ve just hit a problem on this line where we have
two constraints on the same table.
Because they’re on the same table, name is the same.
And we have found a hash collision on result, due to
weakness in how result is being generated.
Adding hashes together for string hashes isn’t safe.
In our case,
"BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyA".GetHashCode()+"itestmanyaid".GetHashCode()
Is equal to:
"BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyB".GetHashCode()+"itestmanybid".GetHashCode()
On V2 runtime.
Changing this code would cause the schemas NHibernate
generates to change :-(
How much of people’s code would this break? (I don’t
use NHibernate in a very conventional way, so I’m not very familiar with
this)
Is it worth submitting a patch, or are we going to have to
live with the broken behaviour for backwards compatibility?
Alun Harford