Hello guys,

 

Yeah, it looks like now that is the solution for this problem. Using
entityBase results in the creation of mappings for entitybase (which results
in an exception because I'm only defining the class with a version element
and that triggers an exception).

 

Regarding the configuration, I was a  little bit puzzled because I tried
adding the ForTypesThatDeriveFrom<EntidadeBase> line I've shown in the
previous mail and with that line I was getting the XML for the EntidadeBase
class but not for the Disciplina class and that was something I wasn't
expecting.

 

Thanks again for your help!

 

---

Luis Abreu

 

From: fluent-nhibernate@googlegroups.com
[mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
Sent: sexta-feira, 9 de Janeiro de 2009 12:14
To: fluent-nhibernate@googlegroups.com
Subject: [fluent-nhib] Re: question on auto mapping

 

Andrew am I correct in thinking this...

 

modeloPersistencia.ForTypesThatDeriveFrom<EntidadeBase>(eb =>
  eb.Version(d => d.Versao)
    .TheColumnNameIs("Versao")
    .SetAttributes(new Attributes {
      {"type", "ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
      {"unsaved-value", "null"},
      {"generated", "always"}}));

 

Should be replaced by one for each entity that has the version column?

 

modeloPersistencia.ForTypesThatDeriveFrom<Entity1>(eb =>
  eb.Version(d => d.Versao)
    .TheColumnNameIs("Versao")
    .SetAttributes(new Attributes {
      {"type", "ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
      {"unsaved-value", "null"},
      {"generated", "always"}}));

 

modeloPersistencia.ForTypesThatDeriveFrom<Entity2>(eb =>
  eb.Version(d => d.Versao)
    .TheColumnNameIs("Versao")
    .SetAttributes(new Attributes {
      {"type", "ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
      {"unsaved-value", "null"},
      {"generated", "always"}}));

If I'm correct in that assumption... Luis, you could probably wrap this up
in a little helper method for the time being. Something along the lines of:

 

public void ConfigureVersion<TEntity>(PersistenceModel model)

{

  model.ForTypesThatDeriveFrom<TEntity>(eb =>

    eb.Version(d => d.Versao)
      .TheColumnNameIs("Versao")
      .SetAttributes(new Attributes {
        {"type", "ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH"},
        {"unsaved-value", "null"},
        {"generated", "always"}}));

}

 

Then in your auto mapping do this:

 

// ... normal auto mapping stuff ...

ConfigureVersion<Entity1>(modeloPersistencia);

ConfigureVersion<Entity2>(modeloPersistencia);

 

On Fri, Jan 9, 2009 at 12:04 PM, Andrew Stewart
<andrew.stew...@i-nnovate.net> wrote:

Hi james

 

Thanks for looking at this for me. Yeah that makes sense as to why it's
producing no xml. Luis are your problems solved now? Unfortunalty there is
no automatic way to map your version column at this time, you'll have to
take your manual mapping and apply it in the FromDerivedFromClass for each
class in your solution. 


I think that should sort your issue out.

 

Andy

 

On Fri, Jan 9, 2009 at 11:48 AM, James Gregory <jagregory....@gmail.com>
wrote:

It's because with the AutoMapping, no mappings are actually generated until
Configure is called.

 

As for your other issue, I haven't forgotten about it I'm just not near a
machine I can debug from. Hopefully tonight or sometime over the weekend
I'll get a chance.

 

On Fri, Jan 9, 2009 at 11:45 AM, Luis Abreu <lab...@gmail.com> wrote:

Ok, that makes sense.

 

Thanks,.

 

---

Luis Abreu

 

From: fluent-nhibernate@googlegroups.com
[mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
Sent: sexta-feira, 9 de Janeiro de 2009 09:39


To: fluent-nhibernate@googlegroups.com
Subject: [fluent-nhib] Re: question on auto mapping

 

You're missing a call to Configure. Before calling
modeloPersistencia.WriteMappingsTo(@"d:\"); call
modeloPersistencia.Configure(nhibernateConfig);

 

On Thu, Jan 8, 2009 at 9:57 PM, Luis Abreu <lab...@gmail.com> wrote:

Btw James, one more question:

 

When using the auto persistence, shouldn't  I be able to save the xml to
disk by using the previous code? It's that I get nothing and stopping the
debugger there I see 0 mappings on the persistencemodel

 

Thanks.

 

 

---

Luis Abreu

 

From: fluent-nhibernate@googlegroups.com
[mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
Sent: quinta-feira, 8 de Janeiro de 2009 16:27


To: fluent-nhibernate@googlegroups.com
Subject: [fluent-nhib] Re: question on auto mapping

 

Hello Luis,

 

I'm away from a machine with Visual Studio on right now, so I don't know how
much help I can be, but lets try to work through your problem.

 

Firstly, why is it that you're using a IUserType for your version? What is
the type that your version property has in your entity? I ask that because
Fluent NHibernate has a few options for mapping Versions and Timestamps.

*       If you call your property Timestamp and give it a type of TimeSpan,
Fluent NHibernate will automatically map that to a Timestamp.
*       If you call your property Version, and give it a type of int or
long, then it will map it as a Version.

Are any of those possible options for you?

 

On Thu, Jan 8, 2009 at 3:40 PM, Luis Abreu <lab...@gmail.com> wrote:


Btw, one more stupid question. If I have this:


var modeloPersistencia =
AutoPersistenceModel.MapEntitiesFromAssemblyOf<Disciplina>()
               .Where(
                   type => type == typeof (Disciplina)
               ) //comecar com disciplina
               .WithConvention(convention =>
                                   {
                                       convention.DefaultLazyLoad = false;
                                       convention.FindIdentity = field =>
field.Name == "Id";
                                       convention.GetTableName = type =>
String.Concat(type.Name, "s");
                                       convention.GetVersionColumnName =
type =>  "Versao";
                                       convention.GetPrimaryKeyNameFromType
= type => String.Concat("Id", type.Name);
                                       convention.IsBaseType = type => type
== typeof (EntidadeBase);
                                   });

modeloPersistencia.WriteMappingsTo(@"d:\");

Shouldn't I get the xml mapping file for class Disciplina on d:? I've tried
and I get nothing there (interestingly, if I add the
modeloPersistencia.ForTypesThatDeriveFro<EntidadeBase> method call then I do
get the xml for EntidadeBase only (which I don't want)...

Thanks.

 

 

 

 

 

 

 

 

 

 

 




-- 

=================
I-nnovate Software - Bespoke Software Development, uk wirral.
http://www.i-nnovate.net

 

 




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to