Yeah, the message was decent. Says it wasn't supported but not really why
(the "component[StartDateTime,EndDateTime]" threw me a little). It was
easy enough to find in the documentation though. Here is the stack trace:
NHibernate.MappingException was unhandled by user code
Message=Type not supported for auditing:
component[StartDateTime,EndDateTime], on entity
ProcessSystem.Domain.Training.Class, property 'TimePeriods'.
Source=NHibernate.Envers
StackTrace:
at
NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.ThrowUnsupportedTypeException(IType
type, String entityName, String propertyName) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\AuditMetadataGenerator.cs:line
522
at
NHibernate.Envers.Configuration.Metadata.CollectionMetadataGenerator.addValueToMiddleTable(IValue
value, XmlElement xmlMapping, QueryGeneratorBuilder queryGeneratorBuilder,
String prefix, String[] joinColumns) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\CollectionMetadataGenerator.cs:line
446
at
NHibernate.Envers.Configuration.Metadata.CollectionMetadataGenerator.AddWithMiddleTable()
in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\CollectionMetadataGenerator.cs:line
315
at
NHibernate.Envers.Configuration.Metadata.CollectionMetadataGenerator.AddCollection()
in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\CollectionMetadataGenerator.cs:line
93
at
NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.addValueInSecondPass(XmlElement
parent, IValue value, ICompositeMapperBuilder currentMapper, String
entityName, EntityXmlMappingData xmlMappingData, PropertyAuditingData
propertyAuditingData, Boolean insertable, Boolean processModifiedFlag) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\AuditMetadataGenerator.cs:line
183
at
NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.AddValue(XmlElement
parent, IValue value, ICompositeMapperBuilder currentMapper, String
entityName, EntityXmlMappingData xmlMappingData, PropertyAuditingData
propertyAuditingData, Boolean insertable, Boolean firstPass, Boolean
processModifiedFlag) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\AuditMetadataGenerator.cs:line
210
at
NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.AddProperties(XmlElement
parent, IEnumerable`1 properties, ICompositeMapperBuilder currentMapper,
ClassAuditingData auditingData, String entityName, EntityXmlMappingData
xmlMappingData, Boolean firstPass) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\AuditMetadataGenerator.cs:line
224
at
NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.GenerateSecondPass(PersistentClass
pc, ClassAuditingData auditingData, EntityXmlMappingData xmlMappingData) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\Metadata\AuditMetadataGenerator.cs:line
508
at
NHibernate.Envers.Configuration.EntitiesConfigurator.Configure(Configuration
cfg, IMetaDataStore metaDataStore, GlobalConfiguration globalCfg,
AuditEntitiesConfiguration verEntCfg, IAuditStrategy auditStrategy,
XmlDocument revisionInfoXmlMapping, XmlElement revisionInfoRelationMapping)
in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\EntitiesConfigurator.cs:line
79
at
NHibernate.Envers.Configuration.AuditConfiguration..ctor(Configuration cfg,
IMetaDataProvider metaDataProvider) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\AuditConfiguration.cs:line
36
at
NHibernate.Envers.Configuration.AuditConfiguration.GetFor(Configuration
cfg) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\AuditConfiguration.cs:line
81
at
NHibernate.Cfg.NhConfigurationExtension.IntegrateWithEnvers(Configuration
configuration, AuditEventListener auditEventListener, IMetaDataProvider
metaDataProvider) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\NhConfigurationExtension.cs:line
27
at
NHibernate.Cfg.NhConfigurationExtension.IntegrateWithEnvers(Configuration
configuration, IMetaDataProvider metaDataProvider) in
d:\develop\NHibernate.Envers\Src\NHibernate.Envers\Configuration\NhConfigurationExtension.cs:line
46
at
ProcessSystem.NHibernateProvider.NHibernateInitializer.Initialize() in
C:\Users\Patrick\Dev\ProcessSystem\app\ProcessSystem.NHibernateProvider\NHibernateInitializer.cs:line
43
at
ProcessSystem.Init.DependencyResolverInitializer.<Initialize>b__1() in
C:\Users\Patrick\Dev\ProcessSystem\app\ProcessSystem.Init\DependencyResolverInitializer.cs:line
18
at
StructureMap.Pipeline.LambdaInstance`1.<>c__DisplayClass8.<.ctor>b__6(IContext
s)
at StructureMap.Pipeline.LambdaInstance`1.build(Type pluginType,
BuildSession session)
InnerException:
For reference, here is the type:
using System;
using SharpLite.Domain;
using System.ComponentModel.DataAnnotations;
namespace ProcessSystem.Domain
{
public class TimePeriod
{
protected TimePeriod() { }
public TimePeriod(DateTime startTime, DateTime endTime)
{
StartDateTime = startTime;
EndDateTime = endTime;
}
public virtual DateTime StartDateTime { get; protected set; }
public virtual DateTime EndDateTime { get; protected set; }
[Required(ErrorMessage = "Date must be provided")]
public virtual DateTime Date
{
get { return StartDateTime.Date; }
}
[Display(Name="Start Time")]
[Required(ErrorMessage = "StartTime must be provided")]
public virtual TimeSpan StartTime
{
get { return StartDateTime.TimeOfDay; }
}
[Required(ErrorMessage = "EndTime must be provided")]
public virtual TimeSpan EndTime
{
get { return EndDateTime.TimeOfDay; }
}
public override bool Equals(object obj)
{...}
public override int GetHashCode()
{...}
}
}
Basically, mapped to two DateTime fields in the DB and treated as a
collection of values:
public class Class : Entity, ITrainingFulfillment
{
public Class()
{
TimePeriods = new List<TimePeriod>();
}
// Lots of other stuff
public virtual IList<TimePeriod> TimePeriods { get; protected set; }
}
I can provide more information if it would be helpful or try to make a test
case for that as well if you would like. I'm hoping I'll actually get some
time today to work on it.
-Patrick
On Thursday, March 22, 2012 8:52:23 AM UTC-5, Roger wrote:
>
> << I'm treating it as a collection of value types (no Id) which I think
> is what section 9.1 of the documentation says is not supported. Am I
> understanding that correctly? >>
>
>
>
> Yes, it’s not currently supported I’m afraid.
>
>
>
> To be honest, don’t really know what happens in your scenario (a
> collection of custom user types). Out of curiousity – don’t you get a
> “nice” (hmm.. well…) exception saying this isn’t supported? What is your
> stack trace?
>
>
>
> /Roger
>
>
>
> *From:* [email protected]
> [mailto:nhusers@googlegroups.com<[email protected]>]
> *On Behalf Of *Patrick
> *Sent:* den 22 mars 2012 14:26
> *To:* [email protected]
> *Subject:* Re: [nhusers] Envers with a PrimitiveType
>
>
>
> Will do. I started working on it last night. Hopefully I'll have
> something worked out by this weekend.
>
> On a related note, I also have an ICompositeUserType that wasn't working
> but I think I know why. I'm treating it as a collection of value types (no
> Id) which I think is what section 9.1 of the documentation says is not
> supported. Am I understanding that correctly?
>
> Thanks,
> Patrick
>
> On Thursday, March 22, 2012 3:51:55 AM UTC-5, Roger wrote:
>
> << Would you be willing to accept a small custom test project?>>
>
>
>
> I really would prefer an unit test. A good starting point is to copy/paste
> a custom user type test already in envers code base – they are here
>
>
> https://bitbucket.org/RogerKratz/nhibernate.envers/src/d9c03ac1dbd0/Src/NHibernate.Envers.Tests/Integration/CustomType<https://bitbucket.org/RogerKratz/nhibernate.envers/src/d9c03ac1dbd0/Src/NHibernate.Envers.Tests/Integration/CustomType>
>
> Simply add a new test in that folder and create a patch (or do a pull
> request on bitbucket).
>
>
>
> Thanks
>
> Roger
>
>
>
> *From:* [email protected]
> [mailto:nhusers@googlegroups.com<[email protected]>]
> *On Behalf Of *Patrick
> *Sent:* den 22 mars 2012 01:04
> *To:* [email protected]
> *Subject:* Re: [nhusers] Envers with a PrimitiveType
>
>
>
> Having never used nHibernate before it will probably take me a while to
> get a test added to the Envers source code, but I'm willing to give it a
> shot. I'll start working on it tonight. Would you be willing to accept a
> small custom test project?
>
> Anyway, Envers very well may support it and I'm just doing something
> wrong. If anybody has an idea of what I might be screwing up (or where to
> start looking), I'd appreciate it.
>
> -Patrick
>
>
> On Wednesday, March 21, 2012 1:50:42 PM UTC-5, Roger wrote:
>
> Custom user types is suppose to work just fine with Envers. Can you send a
> failing test (using hbm mapping) here please?
> https://nhibernate.jira.com/browse/NHE<https://nhibernate.jira.com/browse/NHE>
>
>
> ________________________________
> Från: [email protected] [[email protected]] för Patrick
> Skickat: den 21 mars 2012 19:28
> Till: [email protected]
> Ämne: [nhusers] Envers with a PrimitiveType
>
> I'm trying to get Envers up and running in my project (based on S#arp
> Lite) and am having trouble getting it to work with a custom PrimitiveType.
> Basically, I using the Enumeration class from Jimmy Bogard's site:
> http://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/<http://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/>
>
> and tying it into nHibernate with an EnumerationType<T> that inherits from
> PrimitiveType. That code is mostly stolen from:
>
> http://code.google.com/p/codecampserver/source/browse/trunk/src/Infrastructure.NHibernate/DataAccess/EnumerationType.cs?r=1063<http://code.google.com/p/codecampserver/source/browse/trunk/src/Infrastructure.NHibernate/DataAccess/EnumerationType.cs?r=1063>
>
> My nHibernate mapping for a simple property like this is:
> map.Property(x => x.Type,
> pm =>
> {
> pm.Type<EnumerationType<CourseType>>();
> pm.Column("CourseTypeFk");
> });
>
> However, Envers doesn't seem to be able to deal with it. I just want it
> to treat it as its associated primitive type (int) but I'm getting the
> following exception:
>
> NHibernate.MappingException was unhandled by user code
> Message=Could not determine type for: Enumeration, NHibernate.Envers,
> for columns: NHibernate.Mapping.Column(CourseTypeFk)
> Source=NHibernate
> StackTrace:
> at NHibernate.Mapping.SimpleValue.get_Type()
> at NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping)
> at NHibernate.Mapping.Property.IsValid(IMapping mapping)
> at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
> at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
> at NHibernate.Cfg.Configuration.ValidateEntities()
> at NHibernate.Cfg.Configuration.Validate()
> at NHibernate.Cfg.Configuration.BuildSessionFactory()
> at
> ProcessSystem.Init.DependencyResolverInitializer.<Initialize>b__1()
> at
> StructureMap.Pipeline.LambdaInstance`1.<>c__DisplayClass8.<.ctor>b__6(IContext
>
> s)
> at StructureMap.Pipeline.LambdaInstance`1.build(Type pluginType,
> BuildSession session)
> InnerException:
>
> Any help would be greatly appreciated.
>
> Thanks,
> Patrick
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/Pw0Nkff7kL0J<https://groups.google.com/d/msg/nhusers/-/Pw0Nkff7kL0J>
> .
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> nhusers+unsubscribe@googlegroups.com<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en<http://groups.google.com/group/nhusers?hl=en>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/ASKN74a-YSYJ<https://groups.google.com/d/msg/nhusers/-/ASKN74a-YSYJ>
> .
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> nhusers+unsubscribe@googlegroups.com<[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en<http://groups.google.com/group/nhusers?hl=en>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/Mi76anx1rtoJ<https://groups.google.com/d/msg/nhusers/-/Mi76anx1rtoJ>
> .
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> nhusers+unsubscribe@googlegroups.com<[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en<http://groups.google.com/group/nhusers?hl=en>
> .
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/EiiQSyhBOL8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.