[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread James Gregory
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.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase method call then I
 do
 get the xml for EntidadeBase only (which I don't want)...

 Thanks.








 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread Luis Abreu
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.MapEntitiesFromAssemblyOfDisciplina()
   .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.ForTypesThatDeriveFroEntidadeBase method call then I do
get the xml for EntidadeBase only (which I don't want)...

Thanks.





 

 

 

 

 




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread James Gregory
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.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase method call then I
 do
 get the xml for EntidadeBase only (which I don't want)...

 Thanks.















 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread Andrew Stewart
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.comwrote:

 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.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase 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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread Andrew Stewart
Hi James
Yeah that's correct, I think in theory you could even stick that helper
method in a loop for all classes in namespace or assembly.

Andy

On Fri, Jan 9, 2009 at 12:13 PM, James Gregory jagregory@gmail.comwrote:

 Andrew am I correct in thinking this...

 modeloPersistencia.ForTypesThatDeriveFromEntidadeBase(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.ForTypesThatDeriveFromEntity1(eb =
   eb.Version(d = d.Versao)
 .TheColumnNameIs(Versao)
 .SetAttributes(new Attributes {
   {type, ModeloOO.NH.
 UserTypeTimestamp,ModeloOO.NH},
   {unsaved-value, null},
   {generated, always}}));

 modeloPersistencia.ForTypesThatDeriveFromEntity2(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 ConfigureVersionTEntity(PersistenceModel model)
 {
   model.ForTypesThatDeriveFromTEntity(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 ...
 ConfigureVersionEntity1(modeloPersistencia);
 ConfigureVersionEntity2(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.comwrote:

 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.MapEntitiesFromAssemblyOfDisciplina()
.Where(
type = type == typeof (Disciplina)
) //comecar com disciplina
.WithConvention(convention =
{
convention.DefaultLazyLoad =
 false

[fluent-nhib] Re: question on auto mapping

2009-01-09 Thread James Gregory
I will still look into this behavior, as it is at the very least misleading.

On Fri, Jan 9, 2009 at 7:10 PM, Luis Abreu lab...@gmail.com wrote:

  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 ForTypesThatDeriveFromEntidadeBase 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-nhib] Re: question on auto mapping

2009-01-08 Thread Andrew Stewart
Hi Luis

you need to inform automapper that your base type is EntidadeBase rather
than object, something similar
to below should do the job.

 var autoMapper = AutoPersistenceModel
.MapEntitiesFromAssemblyOfExampleClass()
.Where(t = t.Namespace ==
FluentNHibernate.AutoMap.TestFixtures.SuperTypes)
.WithConvention(c =
{
c.IsBaseType = b = b ==
typeof(EntidadeBase);
});

Cheers

Andy

On Thu, Jan 8, 2009 at 12:27 PM, Luis Abreu lab...@gmail.com wrote:


 Hello guys.

 I've got a stupid question regarding the auto mapping functionality. I have
 the following:

  private static PersistenceModel ObtemAutoConfiguracao()
{
return
 AutoPersistenceModel.MapEntitiesFromAssemblyOfDisciplina()
.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);
});
}

 Now, I'm just trying to run a simple test to check the mapping of a single
 class (Disciplina). I was under the impression that the lambda I've passed
 to the where method should be more than enough for testing only the
 Disciplina class. My problem is that Disciplina inherits from EntidadeBase
 (which defined the Id and Version properties shared by all the entities)
 and
 the autopersistence model insists in generating an insert into
 EntidadeBases
 table when I use the Persistence Specification to test the mappings.

 Can anyone tell me why this happens and how to solve this? Can't I use
 inheritance in my classes and auto mapping? Thanks.


 ---
 Luis Abreu




 



-- 
=
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Andrew Stewart
No Problem,
The version column as a timestamp you can use the Timestamp function of
nhibernate, to do so set the GetVersionColumnName convention to your
timestamp columnname and it should automagically pick that up to. I dont
think you need a custom user type in this situation.

Good Luck

Andy

On Thu, Jan 8, 2009 at 2:24 PM, Luis Abreu lab...@gmail.com wrote:

  Thanks Andrew!



 Btw, one more question: Is there any way to specify the same definition for
 all my version columns? (ex.: all my version columns have the same name and
 I have a custom user type that should be used because on the db the version
 column is of type timestamp)





 Thanks.

 ---

 Luis Abreu



 *From:* fluent-nhibernate@googlegroups.com [mailto:
 fluent-nhibern...@googlegroups.com] *On Behalf Of *Andrew Stewart
 *Sent:* quinta-feira, 8 de Janeiro de 2009 14:00
 *To:* fluent-nhibernate@googlegroups.com
 *Subject:* [fluent-nhib] Re: question on auto mapping



 Hi Luis



 you need to inform automapper that your base type is EntidadeBase rather
 than object, something similar

 to below should do the job.



  var autoMapper = AutoPersistenceModel

 .MapEntitiesFromAssemblyOfExampleClass()

 .Where(t = t.Namespace ==
 FluentNHibernate.AutoMap.TestFixtures.SuperTypes)

 .WithConvention(c =

 {

 c.IsBaseType = b = b ==
 typeof(EntidadeBase);

 });



 Cheers



 Andy



 On Thu, Jan 8, 2009 at 12:27 PM, Luis Abreu lab...@gmail.com wrote:


 Hello guys.

 I've got a stupid question regarding the auto mapping functionality. I have
 the following:

  private static PersistenceModel ObtemAutoConfiguracao()
{
return
 AutoPersistenceModel.MapEntitiesFromAssemblyOfDisciplina()
.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);
});
}

 Now, I'm just trying to run a simple test to check the mapping of a single
 class (Disciplina). I was under the impression that the lambda I've passed
 to the where method should be more than enough for testing only the
 Disciplina class. My problem is that Disciplina inherits from EntidadeBase
 (which defined the Id and Version properties shared by all the entities)
 and
 the autopersistence model insists in generating an insert into
 EntidadeBases
 table when I use the Persistence Specification to test the mappings.

 Can anyone tell me why this happens and how to solve this? Can't I use
 inheritance in my classes and auto mapping? Thanks.


 ---
 Luis Abreu







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


 



-- 
=
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Luis Abreu

Hello again.


One quick thing, it seems at the moment, the property that timestamps must
be called version or timestamp, otherwise you'll have to manually map it.

I tried using Timestamp but then NH tries to use datetime. That's why I'm
using a custom user type and it seems like it's working (at least the
PersistenceSpecification isn't throwing any errors.

So, what I need is to add this from my manual mapping class:


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

So that it is applied to all the types that derive from EntidadeBase class.
I tried this:

var modeloPersistencia =
AutoPersistenceModel.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFromEntidadeBase(
eb = 
eb.Version(d = d.Versao)
  .TheColumnNameIs(Versao)
  .SetAttributes(
  new Attributes
  {
  {type,
ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH},
  {unsaved-value, null},
  {generated, always}
  }
  ));

But by doing this it insists on generating a class definition for
Entidadebase

Thanks.

Luis



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Andrew Stewart
Hi Luis
Ahh, that makes sense now my fault on the understanding. In that case your
only option is to manually map the Version for each class.
If you have time though and we're always willing to except a patch for the
problem, you would need to ammend the AutoMapVersion class.

Cheers

Andy

On Thu, Jan 8, 2009 at 2:56 PM, Luis Abreu lab...@gmail.com wrote:


 Hello again.


 One quick thing, it seems at the moment, the property that timestamps must
 be called version or timestamp, otherwise you'll have to manually map it.

 I tried using Timestamp but then NH tries to use datetime. That's why I'm
 using a custom user type and it seems like it's working (at least the
 PersistenceSpecification isn't throwing any errors.

 So, what I need is to add this from my manual mapping class:


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

 So that it is applied to all the types that derive from EntidadeBase class.
 I tried this:

 var modeloPersistencia =
 AutoPersistenceModel.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFromEntidadeBase(
eb =
eb.Version(d = d.Versao)
  .TheColumnNameIs(Versao)
  .SetAttributes(
  new Attributes
  {
  {type,
 ModeloOO.NH.UserTypeTimestamp,ModeloOO.NH},
  {unsaved-value, null},
  {generated, always}
  }
  ));

 But by doing this it insists on generating a class definition for
 Entidadebase

 Thanks.

 Luis



 



-- 
=
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Luis Abreu



Ahh, that makes sense now my fault on the understanding. In that case your
only option is to manually map the Version for each class. 

I see...can you give more info on how to do that? I mean, should I add
classmaap derived classes with only the version definition and then merge
them with my auto persistence model? If so, which methods am I supposed to
use?

Thanks again.

Luis


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Luis Abreu

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

var modeloPersistencia =
AutoPersistenceModel.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase method call then I do
get the xml for EntidadeBase only (which I don't want)...

Thanks.



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread James Gregory
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.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase method call then I
 do
 get the xml for EntidadeBase only (which I don't want)...

 Thanks.



 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Andrew Stewart
Hi James
He needs to map it to a timestamp, which is where I get lost as you need to
use IUserType to make that work which I have no idea how to use.

Thanks for helping, I think you know how that all works better than myself.

Andy

On Thu, Jan 8, 2009 at 4:27 PM, James Gregory jagregory@gmail.comwrote:

 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.MapEntitiesFromAssemblyOfDisciplina()
.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.ForTypesThatDeriveFroEntidadeBase 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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Luis Abreu

Hello James.

Thanks for the help!

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.

On the class, I have  a Byte[] property which is mapped to a timestamp
column on an sql server express database. According to the docs, the
version element won't be able to match this type. that's why I had to
build my own IUserVersionType. Btw, I've followed this article (though I've
changed the code a little bit - removing those useless try/catch blocks were
really the least I could do!):

http://www.codeproject.com/KB/dotnet/OptLocking_PrefixTable.aspx

Ok, now with manual mappings, I'm able to make it work (at least, I don't
get any exception on my persistency checking. 

Now, the problem is how do I use the same version column for all the
entities where all of them inherit from a base class (EntidadeBase) which is
only there for the OO part...


Any ideas on how to do this?

Luis


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[fluent-nhib] Re: question on auto mapping

2009-01-08 Thread Luis Abreu
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.MapEntitiesFromAssemblyOfDisciplina()
   .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.ForTypesThatDeriveFroEntidadeBase method call then I do
get the xml for EntidadeBase only (which I don't want)...

Thanks.






 




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---