From: Michael T. (JIRA) <nh...@gm...> - 2011-05-24 22:04:47
|
Can't get ByCode mapping to produce not nullable varbinary(max) --------------------------------------------------------------- Key: NH-2739 URL: http://216.121.112.228/browse/NH-2739 Project: NHibernate Issue Type: Bug Components: Mapping by-code Affects Versions: 3.2.0Beta1 Reporter: Michael Teper Priority: Major Trying to map the following class: public class MyData { public byte[] Data { get; set; } } to 'varbinary(max) (not null)' field in SQL Server 2008. mapper.Class<MyData>(map => { map.Property(x => x.Data, m => m.Length(int.MaxValue)); map.Property(x => x.Data, m => m.NotNullable(true)); }); produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Michael T. (JIRA) <nh...@gm...> - 2011-05-25 17:29:54
|
[ http://216.121.112.228/browse/NH-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21194#action_21194 ] Michael Teper commented on NH-2739: ----------------------------------- Nullability might be a problem with SchemaAction = SchemaAutoAction.Recreate. When I blew away the database and started from scratch, the image column was created correctly as not null. Would still like to know if there is anything I can do to have NH generate varbinary(max) in place of image. Thanks! > Can't get ByCode mapping to produce not nullable varbinary(max) > --------------------------------------------------------------- > > Key: NH-2739 > URL: http://216.121.112.228/browse/NH-2739 > Project: NHibernate > Issue Type: Bug > Components: Mapping by-code > Affects Versions: 3.2.0Beta1 > Reporter: Michael Teper > Priority: Major > > Trying to map the following class: > public class MyData > { > public byte[] Data { get; set; } > } > to 'varbinary(max) (not null)' field in SQL Server 2008. > mapper.Class<MyData>(map => > { > map.Property(x => x.Data, m => m.Length(int.MaxValue)); > map.Property(x => x.Data, m => m.NotNullable(true)); > }); > produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Michael T. (JIRA) <nh...@gm...> - 2011-05-25 18:16:06
|
[ http://216.121.112.228/browse/NH-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21195#action_21195 ] Michael Teper commented on NH-2739: ----------------------------------- I tried adding the following bit to specify the type: map.Property(x => x.Data, m => m.Type<BinaryBlobType>()); but got the following error: [MissingMethodException: No parameterless constructor defined for this object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241 System.Activator.CreateInstance(Type type, Boolean nonPublic) +69 System.Activator.CreateInstance(Type type) +6 NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) +39 NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters, Nullable`1 length) +574 [MappingException: Could not instantiate IType BinaryBlobType: System.MissingMethodException: No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type) at NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters, Nullable`1 length)] NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters, Nullable`1 length) +868 NHibernate.Type.TypeFactory.HeuristicType(String typeName, IDictionary`2 parameters) +78 NHibernate.Mapping.SimpleValue.GetHeuristicType() +544 NHibernate.Mapping.SimpleValue.get_Type() +163 NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping) +57 NHibernate.Mapping.Property.IsValid(IMapping mapping) +56 NHibernate.Mapping.PersistentClass.Validate(IMapping mapping) +139 NHibernate.Mapping.RootClass.Validate(IMapping mapping) +45 NHibernate.Cfg.Configuration.ValidateEntities() +240 NHibernate.Cfg.Configuration.Validate() +30 NHibernate.Cfg.Configuration.BuildSessionFactory() +64 > Can't get ByCode mapping to produce not nullable varbinary(max) > --------------------------------------------------------------- > > Key: NH-2739 > URL: http://216.121.112.228/browse/NH-2739 > Project: NHibernate > Issue Type: Bug > Components: Mapping by-code > Affects Versions: 3.2.0Beta1 > Reporter: Michael Teper > Priority: Major > > Trying to map the following class: > public class MyData > { > public byte[] Data { get; set; } > } > to 'varbinary(max) (not null)' field in SQL Server 2008. > mapper.Class<MyData>(map => > { > map.Property(x => x.Data, m => m.Length(int.MaxValue)); > map.Property(x => x.Data, m => m.NotNullable(true)); > }); > produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-26 20:21:00
|
[ http://216.121.112.228/browse/NH-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21207#action_21207 ] Fabio Maulo commented on NH-2739: --------------------------------- You can use the override accepting the IType: map.Type(NHibernateUtil.BinaryBlob) btw the problem is that the BinaryBlobType has 'internal' ctor. > Can't get ByCode mapping to produce not nullable varbinary(max) > --------------------------------------------------------------- > > Key: NH-2739 > URL: http://216.121.112.228/browse/NH-2739 > Project: NHibernate > Issue Type: Bug > Components: Mapping by-code > Affects Versions: 3.2.0Beta1 > Reporter: Michael Teper > Priority: Major > > Trying to map the following class: > public class MyData > { > public byte[] Data { get; set; } > } > to 'varbinary(max) (not null)' field in SQL Server 2008. > mapper.Class<MyData>(map => > { > map.Property(x => x.Data, m => m.Length(int.MaxValue)); > map.Property(x => x.Data, m => m.NotNullable(true)); > }); > produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Michael T. (JIRA) <nh...@gm...> - 2011-05-26 23:48:57
|
[ http://216.121.112.228/browse/NH-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21209#action_21209 ] Michael Teper commented on NH-2739: ----------------------------------- That worked, thank you! Does your last comment mean that the type needs to open up a parameterless constructor? > Can't get ByCode mapping to produce not nullable varbinary(max) > --------------------------------------------------------------- > > Key: NH-2739 > URL: http://216.121.112.228/browse/NH-2739 > Project: NHibernate > Issue Type: Bug > Components: Mapping by-code > Affects Versions: 3.2.0Beta1 > Reporter: Michael Teper > Priority: Major > > Trying to map the following class: > public class MyData > { > public byte[] Data { get; set; } > } > to 'varbinary(max) (not null)' field in SQL Server 2008. > mapper.Class<MyData>(map => > { > map.Property(x => x.Data, m => m.Length(int.MaxValue)); > map.Property(x => x.Data, m => m.NotNullable(true)); > }); > produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-30 15:31:41
|
[ http://216.121.112.228/browse/NH-2739?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo resolved NH-2739. ----------------------------- Resolution: Fixed Fix Version/s: 3.2.0Beta2 > Can't get ByCode mapping to produce not nullable varbinary(max) > --------------------------------------------------------------- > > Key: NH-2739 > URL: http://216.121.112.228/browse/NH-2739 > Project: NHibernate > Issue Type: Bug > Components: Mapping by-code > Affects Versions: 3.2.0Beta1 > Reporter: Michael Teper > Priority: Major > Fix For: 3.2.0Beta2 > > > Trying to map the following class: > public class MyData > { > public byte[] Data { get; set; } > } > to 'varbinary(max) (not null)' field in SQL Server 2008. > mapper.Class<MyData>(map => > { > map.Property(x => x.Data, m => m.Length(int.MaxValue)); > map.Property(x => x.Data, m => m.NotNullable(true)); > }); > produces 'image(null)' -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |