It's not so easy to send you reductive configuration example.
Let me try to explain more detailed how our system is organized.
There are domain models from different application areas (for example, main
domain model and settings domain model, authorization).
Technically they are different builds and different data bases.
We have an opportunity to work with both essences in one transaction in
business logic description.
For example, in neighboring code strings you can see
{
var project = _dalFactory.GetFor<Project>().First(z=>z.Name == "name1");
var settings = _dalFactory.GetFor<Settings>().First(z=>z.Code == "code1")
}
Where project persists to data base 1 and settings persists to data base 2.
It's encoded by the following way (pseudocode):
{
var cfg = new Configuration();
var assemblies = GetAllApplicationAssemblies();
assemblies.Foreach(z=>cfg.AddAssembly(z));
And it's clear that in nhibernate mappings we mentioned data base where
the object persists.
}
Then we need to receive the full audit of domain model No.1.
We filled required attributes to code. For example:
configuration.SetEnversProperty(ConfigurationKey.AuditStrategy,
typeof(DefaultAuditStrategy));
configuration.SetEnversProperty(ConfigurationKey.TrackEntitiesChangedInRevision,
false);
and invoke configuration.IntegrateWithEnvers(new AuditEventListener(), new
AuditMetadataProvider(...));
As it's very important for us to release our domain model from point which
orm now works, we do not set audit attributes to domain model, but encoded
AuditMetadataProvider that it return IDictionary<System.Type, IEntityMeta>
based on types provided to AuditMetadataProvider
(now we have total audit and we provide all domain types here)
Also we create mapping for auditRevisoinEntity by the following way
private HbmMapping CreateRevisionInfoMappingDocument()
{
var mapper = new ModelMapper();
mapper.Class<AuditRevisionEntity>(mapping=>
{
mapping.Id(z=>z.Id,
idMapper=>idMapper.Generator(Generators.Native, z=>z.Params(new
KeyValuePair<string,string>("sequence", "generateidsequence"))));
mapping.Property(z => z.RevisionDate, z => {
z.Insert(true); z.Update(false); });
mapping.Property(z => z.Author, z=> { z.Insert(true);
z.Update(false); });
mapping.Table(typeof(AuditRevisionEntity).Name);
mapping.Schema(_auditSchema);
});
var result =
mapper.CompileMappingForAllExplicitlyAddedEntities();
return result;
}
Everything works perfect! But now we have business requirement to hold
audit for all domain models. So we want to hold audit for settings and
authorization.
Let me remind you, that they are in different data bases.
The first I'd done, was to invoke again configuration.IntegrateWithEnvers
but with other instance of auditMetadataProvider, which aimed to its types.
Nothing happened, because audit configuration invokes once for each
instance configuration.
The second I'd done was to create class CompositeAuditMetadataProvider :
IMetaDataProvider which returns aggregated dictionary of dictionaries of
all aggregated provided IMetaDataProvider (classical pattern composite
realization). I received error "Only one entity may be decorated with
[RevisionEntity]! "
I hope I was successful in explanation and description of our situation. I
think if it try to make an example with configuration it will be not very
simple J
It seems to me the description above will let you understand how our system
is organized
Of course, it's possible to keep all audit information in one data base (it
will be a "plug" to exit the situation, but it will be not very good to
keep audit information from different data bases in one)
Thank you for your attention, I'll be glad to receive any answer from you.
As usual, we have burning deadlines J and we need to present anything for
our business customers next week.
четверг, 19 сентября 2013 г., 16:30:51 UTC+4 пользователь Денис Подзюбан
написал:
>
> Good day!
> I use envers version 1.6.
> Our application works with data from different data bases.
> In present time we used audit for one of them.
> Now we need to use audit for all data bases.
> When we try to to make settings for audit in several data bases we have an
> exeption "Only one entity may be decorated with [RevisionEntity]! "
> Could you please tell us what we should do in this situation?
>
> Thank you in advance
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.