Open GoogleCodeExporter opened 9 years ago
Hello,
Currently we do not support Composite keys in the NHibernate templates. We are
revamping a huge 2.0 release in the future which will include this support. You
can
get around this ID bug by setting a CS_Alias extended property on the ID column
in
your database with the value being the new name of this column (E.G.
Identification).
Thanks
-Blake Niemyjski
Original comment by bniemyjski
on 14 Apr 2010 at 3:46
Hi. I have the same problem.
I have a master table with a Unique key field called "IdPrimaNota".
This table has a relation with a Detail with composite key which is
"IdPrimaNota -
NumeroRiga".
the result i wish to get is a hbm file with a <bag> with a reference to the
detail
table. Likewise I wish to obtain a class with a IList<Detail> property.
When will you release an update?
I tried to use your suggest work aournd but the result is the same.
I have another problem.
To resolve this issue i've tried to modify NHibernateHelper Solution.
I compile the solution and then i put the generated dll in the
Samples\v5.2\Templates\Frameworks\NHibernate\Common\NHibernateHelper
directory.
I have a strange behaviour.
The modfies i have made don't have any effect.
I had the doubt that i have placed the new dll in a wrong path but i suppose is
correct because if i delete the dll, generate process give me an error.
If i raname a method (Init for example) generate process give me an error
but if i modify a method inserting an exception everything is ok !!
I have inserted in a method some code that write a file to a disk but never
happens!!
So the question is: Until I'm waiting for your release..
How can i try to modify the generation process?
Original comment by m.cec...@gmail.com
on 13 May 2010 at 9:13
Today i've tried to modify NHibernateHelper project and use the dll in my
CodeSmith
project.
i don't know why but now my code has effect.
I resolve composite key generation only putting a comment in one row of code of
GetToMany() method of Entity Manager.cs
At the end of procedure there is this code:
else if (!column.IsPrimaryKeyMember)
I've changed it in
else //if (!column.IsPrimaryKeyMember)
this is the entire method
protected void GetToMany()
{
foreach (TableKeySchema tks in _sourceTable.PrimaryKeys)
{
if (tks.ForeignKeyMemberColumns.Count > 1)
{
GetMembers(_sourceTable.ForeignKeyColumns);
}
else
{
ColumnSchema column = tks.ForeignKeyMemberColumns[0];
if (_associationMap.ContainsKey(column) ||
NHibernateHelper.IsExcludedColumn(column.Name))
return;
if (NHibernateHelper.IsManyToMany(column.Table))
{
TableSchema foreignTable = GetToManyTable(column.Table,
_sourceTable);
if (!_excludedTables.Contains(foreignTable))
{
EntityAssociation association = new
EntityAssociation(AssociationTypeEnum.ManyToMany, foreignTable, column);
_associationMap.Add(column, association);
}
else
{
GetMember(column);
}
}
else //if (!column.IsPrimaryKeyMember)
{
if (!_excludedTables.Contains(column.Table))
{
EntityAssociation association = new
EntityAssociation(AssociationTypeEnum.OneToMany, column.Table, column);
_associationMap.Add(column, association);
}
else
{
GetMember(column);
}
}
}
}
}
Original comment by m.cec...@gmail.com
on 13 May 2010 at 2:07
Original issue reported on code.google.com by
metash...@gmail.com
on 6 Apr 2010 at 8:05