Skip to content

Composite Key mapping not hydrating child tables #2230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andreyciocan opened this issue Sep 26, 2019 · 2 comments
Open

Composite Key mapping not hydrating child tables #2230

andreyciocan opened this issue Sep 26, 2019 · 2 comments

Comments

@andreyciocan
Copy link

andreyciocan commented Sep 26, 2019

Hello!

I have some custom mappings done with nhibernate. If my relation is based on simple key, everything works fine. But if my relation is based on composite key, the object children are not hydrated although the sql query generated is correct.

Here is my mapping code:

if (isVersioning)
{
//coposed key not hydrating
	classMapper.Set(setProperty,
		set =>
		{
			set.Table($"{table.DBName}{baseReferenceField.DBName}");
			set.Schema("Versions");
			set.Key(k => k.Columns(c => c.Name(table.DBName), c => c.Name("Version")));
			set.Cascade(Cascade.None);
		},
		elem =>
		{
			elem.ManyToMany(e =>
			{
				e.Column(baseReferenceField.DBName);
				e.Class(setProperty.PropertyType.GetGenericArguments()[0]);
			});
		});
}
else
{
//works fine
	classMapper.Set(setProperty,
		 set =>
		 {
			 set.Table($"{table.DBName}{baseReferenceField.DBName}");
			 set.Schema("Data");
			 set.Key(k => k.Column(table.DBName));
			 set.Cascade(Cascade.None);
		 },
		 elem =>
		 {
			 elem.ManyToMany(e =>
			 {
				 e.Column(baseReferenceField.DBName);
				 e.Class(setProperty.PropertyType.GetGenericArguments()[0]);
			 });
		 });
}
@bahusoid
Copy link
Member

the object children are not hydrated although the sql query generated is correct

I don't understand what it means. Please provide at least code snippet when it happens (does it happen on session.Get or it needs to be a query?). Does it throw any exception (if so provide full stacktrace)?

@andreyciocan
Copy link
Author

Hello!

There is no exception. The query is generated just fine and runs on sql server (as seen from profiler), but my resulting object (from mapping) does not contain any data (again, only when I'm using a composite key for foreign constraint)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants