Possible Dynamic Component Regression in Version 4

78 views
Skip to first unread message

Lee Timmins

unread,
Apr 19, 2017, 11:30:19 AM4/19/17
to nhibernate-development
I've just upgraded an application from version 3.3.4.4000 to 4.1.1.4000 and I have hit a major issue and I wanted to make sure this is a definite bug before filing it as one. Basically I have a mechanism of adding additional fields to entities and storing them in an attributes collection (IDictionary). I do this programatically when I build the configuration (using FluentNhibernate). However the issue I'm having is that the values for each attribute is the same for each field/property. Here's a sample of the code which adds the dynamic component:

Fluently.Configure()
    ...
    .ExposeConfiguration(c => {
        var persistentClass = c.GetClassMapping("MyApp.Models.User");

        // Create the component
        var component = new Component(persistentClass);

        // Add the "Name" property
        var simpleValue = new SimpleValue(persistentClass.Table) { TypeName = "String" };

        simpleValue.AddColumn(new Column("Name") {
            Value = simpleValue,
            Length = 100,
            IsNullable = true
        });

        component.AddProperty(new Property() { Name = "Name", Value = simpleValue });

        // Add the "Email" property
        var simpleValue2 = new SimpleValue(persistentClass.Table) { TypeName = "String" };

        simpleValue2.AddColumn(new Column("Email") {
            Value = simpleValue2,
            Length = 100,
            IsNullable = true
        });

        component.AddProperty(new Property() { Name = "Email", Value = simpleValue2 });

        // Add the component
        persistentClass.AddProperty(new Property() { Name = "Attributes", Value = component });
    })
    .BuildConfiguration();

However if I say:

session.Get<User>().Attributes["Email"]

It has the same value as the "Name" attribute. Looking in the database it has definitely has different values.

I have simplified the above to show the problem. This worked fine before. Please let me know if this indeed a bug or if there is a new way of doing this in version 4.

Thanks

Lee Timmins

unread,
Apr 19, 2017, 11:51:37 AM4/19/17
to nhibernate-development
A quick follow up to this. After further investigation I have found this only applies if the fields are prefixed with the same string which is longer than 4 characters. For example If I prefix the "Name" and "Email" fields with the word "Race" then it works fine. However I prefix it with any string longer than 4 characters e.g. "Contact" then it will give the same value for both properties. It looks like I over simplified my code in the original post.

frederic...@free.fr

unread,
Apr 20, 2017, 1:26:44 PM4/20/17
to nhibernate-development
I think https://groups.google.com/forum/#!forum/nhusers would be more suitable for your question.
As for finding out if it is a known bug, check the Jira: https://nhibernate.jira.com
Test cases welcome, read https://github.com/nhibernate/nhibernate-core/blob/master/CONTRIBUTING.md for more on how to best supply them.

Lee Timmins

unread,
Apr 21, 2017, 5:45:25 AM4/21/17
to nhibernate-development
Thanks for replying. I'm trying to follow the steps to create a pull request. So far I have forked and cloned my repository (to a folder on my desktop). I then ran the ShowBuildMenu.bat and executed A, B (set my connection string to a database I have setup called "NHibernate" using SQL Server 2008), D (this did nothing until I exected E but it still fails saying it cannot find the TestDatabaseSetup.dll - I think this is relelated to E failing), E (this fails when trying to run the Tools\msbuild.cmd file).

Please note I have Visual Studio 2012 and 2015 installed. When I open the src\NHibernate.sln file it opens in Visual Studio 2012 and when I try to build the project I get all sorts of errors. Again I think this is related to E failing above. Looking in to the msbuild.cmd file it tries to execute "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe". I did a search on Google for MSBuild 15 and found it's supposed to be part of the .NET Core SDK. I've just installed that but I still can't get it to build.

I'd appreciate any help.

Thanks

Alexander Zaytsev

unread,
Apr 21, 2017, 7:18:03 PM4/21/17
to nhibernate-development
It requires Visual Studio 2017 / Ms Build Tools 2017 to build
--

---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lee Timmins

unread,
Apr 25, 2017, 9:32:03 AM4/25/17
to nhibernate-development
Thanks, I'll get onto my boss to upgrade.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-development+unsub...@googlegroups.com.

frederic...@free.fr

unread,
Apr 26, 2017, 6:28:32 AM4/26/17
to nhibernate-development
A point to consider: Visual Studio 2017 Community Edition is enough and is allowed to be used by any company when contributing to open source projects.
An unlimited number of users within an organization can use Visual Studio Community for the following scenarios: in a classroom learning environment, for academic research, or for contributing to open source projects.
Organizational License. If you are an organization, your users may use the software as follows:
Any number of your users may use the software to develop and test applications released under Open Source Initiative (OSI) approved open source software licenses.

NHibernate is LGPL, which is among OSI approved licences. https://opensource.org/licenses

Lee Timmins

unread,
Apr 27, 2017, 3:49:07 AM4/27/17
to nhibernate-development
Thanks I now have it working. I'm going to file a few bugs for issues I have been having since upgrading to version 4. I will also attempt to submit a pull request but no promises as I'm relatively new to the code, although I have been using it for several years.

Lee Timmins

unread,
Apr 27, 2017, 10:40:20 AM4/27/17
to nhibernate-development
One minor problem I'm running into is when I run option D of the "ShowBuildMenu.bat" to execute the tests, it passes okay but throws the error "Database 'nhibernate' already exists. Choose a different database name.". However if delete the nhibernate database it fails saying it cannot connect to the database.


On Wednesday, 26 April 2017 11:28:32 UTC+1, frederic...@free.fr wrote:

frederic...@free.fr

unread,
Apr 27, 2017, 12:16:22 PM4/27/17
to nhibernate-development
I do not have this issue. I launch it with an existing nhibernate database, using a user having sysadm role, and which does not have the nhibernate database as default db (otherwise this could cause issues).
Reply all
Reply to author
Forward
0 new messages