-
Notifications
You must be signed in to change notification settings - Fork 687
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
Default enum type mapping prevents using imported type in HQL queries #151
Comments
Tested out some other types: // This works
Map (x => x.Bar).CustomType ("");
Map (x => x.Bar).CustomType (typeof(NHibernate.Type.EnumType<Bar>));
// This does not work
Map (x => x.Bar);
Map (x => x.Bar).CustomType (typeof(FluentNHibernate.Mapping.GenericEnumMapper<Bar>));
Map (x => x.Bar).CustomType (typeof(NHibernate.Type.EnumStringType<Bar>)); Looking at the various types, the key seems to be NHibernate.Type.PersistentEnumType, which seems to be the default class NHibernate uses if you don't specify. |
this should work too Map (x => x.Status).CustomType(); |
I researched this problem a bit. This can be fixed by simple change (check referenced commit) No Unit tests are red. Everything is green. |
Thanks |
This is a breaking change. This change will make all the default strings enums being saved as integer types (which is the normal behaviour of Nhibernate). I also researched how the schema looks like and the reason why this works Map (x => x.Bar).CustomType (""); Is that, with this statement enum is stored as int. |
Problem
Mapping an enum property without specifying a custom type prevents using the imported enum type in HQL queries.
e.g.
See, https://github.com/chilversc/FNH-EnumError for a sample project that reproduces this error.
Expected behaviour
The query should work and return a list of foo's that have their status equal to Y.
Actual behaviour
The query fails with an exception from the database driver with the message, "Column Y not found".
Workaround
In the mapping specify
Map(x => x.Status).CustomType("")
The text was updated successfully, but these errors were encountered: