AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

nHibernate - Duplicate Methods, Variables etc.. #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I've run the nhibernate template (Codesmith v5 with the latest template)
against the AdventureWorks database and discovered a number of bugs..

For business objects the following problems have been found.
1. private member collection variables are duplicated if more than one
foreign key relationship exists for the same table e.g. SalesDetailsHeader
has 2 relationships to Address.
2. private member variables are duplicated for the same reason as 1.
3. public property accessors are duplicated for the same reason as 1.
4. partial methods are duplicated for the same reason as 1.

For generated hbm files.
5. as above for 1 to 4 the corresponding elements are duplicated.

I've found that certainly 1 and 2 are fixed by adding the
MemberColumnSchema.Name to the variable name generated (the same fix may
apply to 3, 4 and 5). I'm still working through the templates but I am
happy to contribute the work I've done once complete.

Ticket: 40506

Original issue reported on code.google.com by bniemyjski on 14 Oct 2008 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 14 Oct 2008 at 3:30

GoogleCodeExporter commented 9 years ago
If you try AdventureWorks with the latest nHibernate template you'll find some 
of the
generated code is duplicated where more than one foreign key exists for the same
table e.g. SalesOrderHeader and Address has BilltoAddress and SaletoAddress
relationships. I get a private member generated twice. Private member variables,
properties and hbm files are all affected.

I tried the latest nightly build as I noticed that the readme states this (or 
similar
bug) is fixed, but no joy. A dirty fix is to add the MemberColumnSchema.Name 
property
onto the generated code in question - this enforces uniqueness - which 
eventually
allowed me to compile but the tests dont work now. I'm getting
FKUnmatchingColumnsException errors.

private Employee _employee

changes to...

private Employee _employeeManagerId

which isn't a great naming convention to identify the employee's manager. Can 
anyone
recommend a better fix?

http://community.codesmithtools.com/forums/t/8951.aspx

Original comment by bniemyjski on 14 Oct 2008 at 3:35

GoogleCodeExporter commented 9 years ago
We recognize that this is an issue, and it has been added our backlog.
It is on my schedule to try and resolve this issue by next week; I will provide 
an
update when it's finished.

Thanks,
Tom

Original comment by tdupont...@gmail.com on 14 Oct 2008 at 6:30

GoogleCodeExporter commented 9 years ago
I am glad to report that we have done a large update on the back end of our
NHibernate templates!
We should now have better logic that prevents duplication of columns and 
associations
in the business entities.

However, the main problem we were experiencing was with Composite Foreign Keys, 
and
unfortunately we have not yet been able to resolve all of these issues.
Thus, we do not currently support generating associations for Composite Foreign 
Keys,
instead we generate those columns as properties.

We hope you enjoy these updates; please keep the great feedback coming!

Thanks,
Tom

Original comment by tdupont...@gmail.com on 28 Oct 2008 at 8:53

GoogleCodeExporter commented 9 years ago

Original comment by shannon....@gmail.com on 6 Oct 2009 at 5:23