[fluent-nhib] Re: Possible Problem with Query Method in IRepository
I'll take a look at your GenericRepository, see if I can replicate the issue. On Thu, Jan 8, 2009 at 4:52 AM, Josh Pollard j...@glmotorsports.net wrote: well now i feel dumb and bad. first off, i wasnt able to get your example to compile, but it was probably more due to my lack of knowledge around sqlite than anything. so i decided to write another unit test of my own that basically looks like this: Dim flRepos As New Repository(session) Dim id As Integer = 1 Dim product = flRepos.Query(Of Product)(Function(p As Product) p.Id = id).FirstOrDefault() Assert.AreEqual(id, product.Id) and it passed. so the problem doesnt look like its in fluent nhibernate from that stand point. But if you look up at my original question, you'll see that I'm trying to wrap the fluent nhibernate repository in my own generic repository. When I then call the GetById method, which I believe does the same thing as what I have in the code in this message, I get an exception trying to cast Int to Product. Does that make sense? On Jan 7, 5:42 pm, James Gregory jagregory@gmail.com wrote: Josh: I've tried reproducing your problem, but I haven't been able to. I created a Product class, a ProductMap, and then wrote a little unit test to see if it worked, and it did. TestFixture() _ Public Class VbLinqTests Private _source As ISessionSource SetUp() _ Public Sub CreateDatabase() Dim properties As IDictionary(Of String, String) = New SQLiteConfiguration() _ .UseOuterJoin() _ .InMemory() _ .ToProperties() _source = New SingleConnectionSessionSourceForSQLiteInMemoryTesting(properties, New TestModel()) _source.BuildSchema() End Sub Test() _ Public Sub TestLinq() Dim flRepos As New Repository(_source) flRepos.Save(New Product()) flRepos.Save(New Product()) flRepos.Save(New Product()) flRepos.Save(New Product()) Dim product As Product = flRepos.Query(Of Product)(Function(p As Product) p.Id 1).ToList().FirstOrDefault Assert.NotNull(product) End Sub End Class Can you try running that yourself to see what happens? On Tue, Jan 6, 2009 at 11:00 PM, Josh Pollard j...@glmotorsports.net wrote: I did some more investigating and it looks like Linq2NHib only pukes when using lambda expressions in VB. The following works: Dim product = (From p In session.Linq(Of Product)() _ Where p.Id = testId _ Select p).FirstOrDefault() Obviously that isn't using Fluent NHib at all. So the question is, how do I use Fluent NHib without using lambdas? I think the problem is that I don't know what us as my in Any ideas on how to cram a full linq query into the Fluent NHib Query method? On Jan 5, 3:31 pm, Jeremy Skinner jer...@jeremyskinner.co.uk wrote: I can't be certain as I haven't got VB installed to test this, but it certainly appears to be the case. Linq to NHibernate's unit tests are all in C# so it doesn't surprise me that the differences in VB's expression trees have been missed. 2009/1/5 RalyDSM j...@glmotorsports.net so I guess i need to take this problem to the linq-to-nhibernate guys... On Jan 5, 3:19 pm, Jeremy Skinner jer...@jeremyskinner.co.uk wrote: Yep, you'll notice there's no where clause on the query. Its loading the entire table then performing an in-memory linq query. 2009/1/5 RalyDSM j...@glmotorsports.net are you SURE about the compile thing? When I turn on the show_sql property in NHibernate this is the query that is written: SELECT this_.Id as Id2_0_, this_.Title as Title2_0_ FROM [Product] this_ On Jan 5, 3:04 pm, Jeremy Skinner jer...@jeremyskinner.co.uk wrote: I don't think this is an issue with the Repository, rather an issue with Linq to NHibernate. The VB and C# compilers (unhelpfully) create expression trees differently. My guess is the Linq to NHibernate code does not parse VB expression trees correctly (I can't verify this as I don't have VB installed on this machine). You don't want to be calling where.Compile() - this causes the expression tree to be compiled into a delegate and can no longer be translated into SQL - instead this ends up loading the entire table into your application and then doing an *in-memory* filter (bypassing Linq to NHibernate's expression tree parsing). Jeremy 2009/1/5 James Gregory jagregory@gmail.com That's very interesting. Unfortunately, the bits in the Framework project are rather neglected, so there may
[fluent-nhib] Re: Possible Problem with Query Method in IRepository
Right, after a lot more experimentation I've come to the conclusion that it's to do with generic type parameters. I've basically extracted the logic out of your GenericRepository, reducing it until I can replicate the issue in the smallest possible form. Take the following test: Test() _ Public Sub TestLinq() Dim flRepos As New Repository(_source) flRepos.Save(New Product()) flRepos.Save(New Product()) flRepos.Query(Function(x As Product) (x.Id = 2)) GetById(Of Product)(2, flRepos) End Sub Public Function GetById(Of T As IHasIntId)(ByVal Id As Integer, ByVal flRepos As IRepository) As T() Return flRepos.Query(Function(x As T) (x.Id = 2)) End Function There's a direct Query call on the repository, then there's a call to the same method inside a helper method that uses a generic type. The direct Query call succeeds, but the GetById call fails. If you change the helper method to this: Public Function GetById(Of T As IHasIntId)(ByVal Id As Integer, ByVal flRepos As IRepository) As Product() Return flRepos.Query(Function(x As Product) (x.Id = 2)) End Function Then it suddenly works. Notice the T is not actually used and it's hard coded to Product. My main conclusion is that this is definitely not a Fluent NHibernate issue. It's something wrong with how Linq to NHibernate handles VBs generic parameters. A workaround, and it's not a nice one, is to either have a repository per type, or create your generic repository in C# (I tried this and it works without any trouble). On Thu, Jan 8, 2009 at 10:42 AM, James Gregory jagregory@gmail.comwrote: I'll take a look at your GenericRepository, see if I can replicate the issue. On Thu, Jan 8, 2009 at 4:52 AM, Josh Pollard j...@glmotorsports.netwrote: well now i feel dumb and bad. first off, i wasnt able to get your example to compile, but it was probably more due to my lack of knowledge around sqlite than anything. so i decided to write another unit test of my own that basically looks like this: Dim flRepos As New Repository(session) Dim id As Integer = 1 Dim product = flRepos.Query(Of Product)(Function(p As Product) p.Id = id).FirstOrDefault() Assert.AreEqual(id, product.Id) and it passed. so the problem doesnt look like its in fluent nhibernate from that stand point. But if you look up at my original question, you'll see that I'm trying to wrap the fluent nhibernate repository in my own generic repository. When I then call the GetById method, which I believe does the same thing as what I have in the code in this message, I get an exception trying to cast Int to Product. Does that make sense? On Jan 7, 5:42 pm, James Gregory jagregory@gmail.com wrote: Josh: I've tried reproducing your problem, but I haven't been able to. I created a Product class, a ProductMap, and then wrote a little unit test to see if it worked, and it did. TestFixture() _ Public Class VbLinqTests Private _source As ISessionSource SetUp() _ Public Sub CreateDatabase() Dim properties As IDictionary(Of String, String) = New SQLiteConfiguration() _ .UseOuterJoin() _ .InMemory() _ .ToProperties() _source = New SingleConnectionSessionSourceForSQLiteInMemoryTesting(properties, New TestModel()) _source.BuildSchema() End Sub Test() _ Public Sub TestLinq() Dim flRepos As New Repository(_source) flRepos.Save(New Product()) flRepos.Save(New Product()) flRepos.Save(New Product()) flRepos.Save(New Product()) Dim product As Product = flRepos.Query(Of Product)(Function(p As Product) p.Id 1).ToList().FirstOrDefault Assert.NotNull(product) End Sub End Class Can you try running that yourself to see what happens? On Tue, Jan 6, 2009 at 11:00 PM, Josh Pollard j...@glmotorsports.net wrote: I did some more investigating and it looks like Linq2NHib only pukes when using lambda expressions in VB. The following works: Dim product = (From p In session.Linq(Of Product)() _ Where p.Id = testId _ Select p).FirstOrDefault() Obviously that isn't using Fluent NHib at all. So the question is, how do I use Fluent NHib without using lambdas? I think the problem is that I don't know what us as my in Any ideas on how to cram a full linq query into the Fluent NHib Query method? On Jan 5, 3:31 pm, Jeremy Skinner jer...@jeremyskinner.co.uk wrote: I can't be certain as I haven't got VB installed to test this, but it certainly appears to be the case. Linq to NHibernate's unit tests are all in C# so it doesn't surprise me that the differences in VB's expression trees have been missed. 2009/1/5 RalyDSM j...@glmotorsports.net so I
[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 --~--~-~--~~~---~--~~ 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: Automapping a complex inheritance
Hi Luis you need to inform automapper that your base type is EntityBase 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(EntityBase); }); Cheers Andy On Thu, Jan 8, 2009 at 1:28 PM, Adriano adriano.mach...@gmail.com wrote: Hi. I'm new to FluentNHibernate / NHibernate, and I would like to ask you guys a question about mapping complex (or deep) inheritance situations. The class hierarchy I have is the following: class Asset : EntityBase { // ... } class Fund : Asset { // ... } class EquityFund : Fund { // ... } class FixedIncomeFund : Fund { // } class Trade : EntityBase { public Asset Asset { get; set; } } I would like to use the AutoMap feature, but NHibernate keep telling me that the class Fund is being duplicated in the mappings. What am I missing? -- = 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
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
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
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
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: Automapping a complex inheritance
I forgot to mention that I had already set the baseclass to my EntityBase class. On 8 jan, 12:00, Andrew Stewart andrew.stew...@i-nnovate.net wrote: Hi Luis you need to inform automapper that your base type is EntityBase 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(EntityBase); }); Cheers Andy On Thu, Jan 8, 2009 at 1:28 PM, Adriano adriano.mach...@gmail.com wrote: Hi. I'm new to FluentNHibernate / NHibernate, and I would like to ask you guys a question about mapping complex (or deep) inheritance situations. The class hierarchy I have is the following: class Asset : EntityBase { // ... } class Fund : Asset { // ... } class EquityFund : Fund { // ... } class FixedIncomeFund : Fund { // } class Trade : EntityBase { public Asset Asset { get; set; } } I would like to use the AutoMap feature, but NHibernate keep telling me that the class Fund is being duplicated in the mappings. What am I missing? -- = I-nnovate Software - Bespoke Software Development, uk wirral.http://www.i-nnovate.net- Ocultar texto entre aspas - - Mostrar texto entre aspas - --~--~-~--~~~---~--~~ 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
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: Debugging Xml Output by FNH
Hi Troy You should be able to use PersistenceModel to write the mappings instead. Andy On Thu, Jan 8, 2009 at 3:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? -- = 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: Debugging Xml Output by FNH
To see my xml in testexplorer i created this:Console.Write(XElement.Parse(CreateMapping(new MappingVisitor()).FirstChild.NextSibling.InnerXml, LoadOptions.PreserveWhitespace).ToString()); Not much, but readable... On Thu, Jan 8, 2009 at 5:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? --~--~-~--~~~---~--~~ 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: Automapping a complex inheritance
It seems that the auto mapping of inheritance isn't clever enough to map that model yet, sorry. You'll have to manually map all descendants of Asset Sorry I hadn't spotted that sneaky one. Andy On Thu, Jan 8, 2009 at 3:29 PM, Adriano adriano.mach...@gmail.com wrote: I forgot to mention that I had already set the baseclass to my EntityBase class. On 8 jan, 12:00, Andrew Stewart andrew.stew...@i-nnovate.net wrote: Hi Luis you need to inform automapper that your base type is EntityBase 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(EntityBase); }); Cheers Andy On Thu, Jan 8, 2009 at 1:28 PM, Adriano adriano.mach...@gmail.com wrote: Hi. I'm new to FluentNHibernate / NHibernate, and I would like to ask you guys a question about mapping complex (or deep) inheritance situations. The class hierarchy I have is the following: class Asset : EntityBase { // ... } class Fund : Asset { // ... } class EquityFund : Fund { // ... } class FixedIncomeFund : Fund { // } class Trade : EntityBase { public Asset Asset { get; set; } } I would like to use the AutoMap feature, but NHibernate keep telling me that the class Fund is being duplicated in the mappings. What am I missing? -- = I-nnovate Software - Bespoke Software Development, uk wirral. http://www.i-nnovate.net- Ocultar texto entre aspas - - Mostrar texto entre aspas - -- = 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] Fluent NHibernate and the Windsor NHibernate Integration Facility
I'm trying to use Fluent NHibernate with Windsor's NHibernate Integration Facility. I was wondering if anyone else has faced this issue. We've come up with this solution, but I'd like to know if there's better way: FNH needs to get access to the NH config. I've used a custom IConfigurationBuilder (from the NH integration facility) and registered it with the facitlity: facility id=nhibernate isWeb=false type=Castle.Facilities.NHibernateIntegration.NHibernateFacility, Castle.Facilities.NHibernateIntegration configurationBuilder=WindsorNHibernate.Services.FluentNHibernateConfigurationBuilder, WindsorNHibernate My custom configuration builder looks like this: public class FluentNHibernateConfigurationBuilder : DefaultConfigurationBuilder { public new Configuration GetConfiguration(IConfiguration config) { Configuration cfg = new Configuration(); ApplyConfigurationSettings(cfg, config.Children[settings]); RegisterAssemblies(cfg, config.Children[assemblies]); RegisterResources(cfg, config.Children[resources]); RegisterListeners(cfg, config.Children[listeners]); // Fluent NH call cfg.AddMappingsFromAssembly(Assembly.GetExecutingAssembly()); return cfg; } } Thanks Mike --~--~-~--~~~---~--~~ 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: Debugging Xml Output by FNH
As Andrew said, the PersistenceModel has a WriteMappingsTo(string folder)method. On Thu, Jan 8, 2009 at 4:03 PM, Mart Leet mal...@gmail.com wrote: To see my xml in testexplorer i created this:Console.Write(XElement.Parse(CreateMapping(new MappingVisitor()).FirstChild.NextSibling.InnerXml, LoadOptions.PreserveWhitespace).ToString()); Not much, but readable... On Thu, Jan 8, 2009 at 5:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? --~--~-~--~~~---~--~~ 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: Debugging Xml Output by FNH
I believe that using the PersisitnceModel.WritemappingsTo yields diferent results than the XML that is acutally used if you don't write the mapings though. By different, I mean the order of the properties are different. So as long as you are not concerned about what order the properties come in then it should be fine. The other way is to do something like this: Use an IMappingVisitor to do this: // This code is the caller to write the files IListIMapGenerator mappers = GeneratorHelper.GetMapGenerators(); foreach (var mapper in mappers) { mapper.Generate().Save(mapper.FileName); } Each map I want to write out implements IMapGenerator public XmlDocument Generate() { return CreateMapping(new MappingVisitor()); } IMapGenerator code: public interface IMapGenerator { string FileName { get; } XmlDocument Generate(); } On Jan 8, 10:05 am, James Gregory jagregory@gmail.com wrote: As Andrew said, the PersistenceModel has a WriteMappingsTo(string folder)method. On Thu, Jan 8, 2009 at 4:03 PM, Mart Leet mal...@gmail.com wrote: To see my xml in testexplorer i created this:Console.Write(XElement.Parse(CreateMapping(new MappingVisitor()).FirstChild.NextSibling.InnerXml, LoadOptions.PreserveWhitespace).ToString()); Not much, but readable... On Thu, Jan 8, 2009 at 5:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? --~--~-~--~~~---~--~~ 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
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
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: Debugging Xml Output by FNH
I'm still confused by how they can be different orders. This is how the mappings are added to NHibernate: public virtual void Configure(Configuration configuration) { _configured = true; MappingVisitor visitor = new MappingVisitor(_conventions, configuration, _chain); _mappings.ForEach(mapping = mapping.ApplyMappings(visitor)); } This is how they're written out: public void WriteMappingsTo(string folder) { DiagnosticMappingVisitor visitor = new DiagnosticMappingVisitor(folder, _conventions, null, _chain); _mappings.ForEach(m = m.ApplyMappings(visitor)); } As you can see, they're nigh-on-identical. On Thu, Jan 8, 2009 at 4:17 PM, Ryan Kelley rpkel...@gmail.com wrote: I believe that using the PersisitnceModel.WritemappingsTo yields diferent results than the XML that is acutally used if you don't write the mapings though. By different, I mean the order of the properties are different. So as long as you are not concerned about what order the properties come in then it should be fine. The other way is to do something like this: Use an IMappingVisitor to do this: // This code is the caller to write the files IListIMapGenerator mappers = GeneratorHelper.GetMapGenerators(); foreach (var mapper in mappers) { mapper.Generate().Save(mapper.FileName); } Each map I want to write out implements IMapGenerator public XmlDocument Generate() { return CreateMapping(new MappingVisitor()); } IMapGenerator code: public interface IMapGenerator { string FileName { get; } XmlDocument Generate(); } On Jan 8, 10:05 am, James Gregory jagregory@gmail.com wrote: As Andrew said, the PersistenceModel has a WriteMappingsTo(string folder)method. On Thu, Jan 8, 2009 at 4:03 PM, Mart Leet mal...@gmail.com wrote: To see my xml in testexplorer i created this:Console.Write(XElement.Parse(CreateMapping(new MappingVisitor()).FirstChild.NextSibling.InnerXml, LoadOptions.PreserveWhitespace).ToString()); Not much, but readable... On Thu, Jan 8, 2009 at 5:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? --~--~-~--~~~---~--~~ 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: Fluent NHibernate and the Windsor NHibernate Integration Facility
Woops, sorry that code above won't work. You have to create you own IConfigurationBuilder. This one is tested and works: /// summary /// Default imlementation of see cref=IConfigurationBuilder/ /// /summary public class FluentNHibernateConfigurationBuilder : IConfigurationBuilder { /// summary /// Builds the Configuration object from the specifed configuration /// /summary /// param name=config/param /// returns/returns public Configuration GetConfiguration(IConfiguration config) { Configuration cfg = new Configuration(); ApplyConfigurationSettings(cfg, config.Children[settings]); cfg.AddMappingsFromAssembly(typeof(Order).Assembly); AdditionalConfiguration(config, cfg); return cfg; } /// summary /// Override this method to provide additional configuration /// /summary /// param name=config/param /// param name=cfg/param public virtual void AdditionalConfiguration(IConfiguration config, Configuration cfg) {} /// summary /// Applies the configuration settings. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected void ApplyConfigurationSettings(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String key = item.Attributes[key]; String value = item.Value; cfg.SetProperty(key, value); } } } --~--~-~--~~~---~--~~ 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] PersistentModel - Make Mappings Property
Does it make sense to want a public property to access the mappings in a persistent model? I can imagine many uses for this: * I want a DiagnosticMappingVisitor that does not need to write to a folder * I want to do some kind of post processing to the mappings * I want to build scaffolding (like rails style scaffolding) from the metadata in the model This should be very easy to do, I was just wondering if this isn't exposed on purpose. 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: PersistentModel - Make Mappings Property
Sorry, subject should be Persist_ence_Model On Jan 8, 10:30 am, Chris Bilson cbil...@gmail.com wrote: Does it make sense to want a public property to access the mappings in a persistent model? I can imagine many uses for this: * I want a DiagnosticMappingVisitor that does not need to write to a folder * I want to do some kind of post processing to the mappings * I want to build scaffolding (like rails style scaffolding) from the metadata in the model This should be very easy to do, I was just wondering if this isn't exposed on purpose. 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: Fluent NHibernate and the Windsor NHibernate Integration Facility
No luck with the trunk of castle though as it relies on 2.1 and fluent nhibernate so far seems compiled against 2.0. Is there a way to change that when compiling fluent nhibernate? Or is there a 2.0 compat nhibernate facility in castle? I've had to revert to using a SessionManager and manage my sessions myself. Not nice! -Original Message- From: fluent-nhibernate@googlegroups.com [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of Mike Hadlow Sent: 08 January 2009 17:02 To: Fluent NHibernate Subject: [fluent-nhib] Re: Fluent NHibernate and the Windsor NHibernate Integration Facility Woops, sorry that code above won't work. You have to create you own IConfigurationBuilder. This one is tested and works: /// summary /// Default imlementation of see cref=IConfigurationBuilder/ /// /summary public class FluentNHibernateConfigurationBuilder : IConfigurationBuilder { /// summary /// Builds the Configuration object from the specifed configuration /// /summary /// param name=config/param /// returns/returns public Configuration GetConfiguration(IConfiguration config) { Configuration cfg = new Configuration(); ApplyConfigurationSettings(cfg, config.Children[settings]); cfg.AddMappingsFromAssembly(typeof(Order).Assembly); AdditionalConfiguration(config, cfg); return cfg; } /// summary /// Override this method to provide additional configuration /// /summary /// param name=config/param /// param name=cfg/param public virtual void AdditionalConfiguration(IConfiguration config, Configuration cfg) {} /// summary /// Applies the configuration settings. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected void ApplyConfigurationSettings(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String key = item.Attributes[key]; String value = item.Value; cfg.SetProperty(key, value); } } } --~--~-~--~~~---~--~~ 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: Debugging Xml Output by FNH
The only thing I can think of is maybe this in ClassMapBase: protected void writeTheParts(XmlElement classElement, IMappingVisitor visitor) { _properties.Sort(new MappingPartComparer()); foreach (IMappingPart part in _properties) { part.Write(classElement, visitor); } } where it does the sort on the list before it adds them. Because when I use CreateMapping vs WriteMappingsTo they are different and CreateMapping is consistent with what the db/NH sees, unless you do WriteMappingsTo then that is consistent. On Jan 8, 10:35 am, James Gregory jagregory@gmail.com wrote: I'm still confused by how they can be different orders. This is how the mappings are added to NHibernate: public virtual void Configure(Configuration configuration) { _configured = true; MappingVisitor visitor = new MappingVisitor(_conventions, configuration, _chain); _mappings.ForEach(mapping = mapping.ApplyMappings(visitor)); } This is how they're written out: public void WriteMappingsTo(string folder) { DiagnosticMappingVisitor visitor = new DiagnosticMappingVisitor(folder, _conventions, null, _chain); _mappings.ForEach(m = m.ApplyMappings(visitor)); } As you can see, they're nigh-on-identical. On Thu, Jan 8, 2009 at 4:17 PM, Ryan Kelley rpkel...@gmail.com wrote: I believe that using the PersisitnceModel.WritemappingsTo yields diferent results than the XML that is acutally used if you don't write the mapings though. By different, I mean the order of the properties are different. So as long as you are not concerned about what order the properties come in then it should be fine. The other way is to do something like this: Use an IMappingVisitor to do this: // This code is the caller to write the files IListIMapGenerator mappers = GeneratorHelper.GetMapGenerators(); foreach (var mapper in mappers) { mapper.Generate().Save(mapper.FileName); } Each map I want to write out implements IMapGenerator public XmlDocument Generate() { return CreateMapping(new MappingVisitor()); } IMapGenerator code: public interface IMapGenerator { string FileName { get; } XmlDocument Generate(); } On Jan 8, 10:05 am, James Gregory jagregory@gmail.com wrote: As Andrew said, the PersistenceModel has a WriteMappingsTo(string folder)method. On Thu, Jan 8, 2009 at 4:03 PM, Mart Leet mal...@gmail.com wrote: To see my xml in testexplorer i created this:Console.Write(XElement.Parse(CreateMapping(new MappingVisitor()).FirstChild.NextSibling.InnerXml, LoadOptions.PreserveWhitespace).ToString()); Not much, but readable... On Thu, Jan 8, 2009 at 5:57 PM, Troy Goode troygo...@gmail.com wrote: I know from my recent foray into automapping that I can see what the XML produced by the automapper is using: automapper.WriteMappingsTo(folderpath); What is the easiest way to accomplish the same thing (see the generated XML) when using ClassMapT? --~--~-~--~~~---~--~~ 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: Automapping a complex inheritance
Ok. 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 16:04 To: fluent-nhibernate@googlegroups.com Subject: [fluent-nhib] Re: Automapping a complex inheritance It seems that the auto mapping of inheritance isn't clever enough to map that model yet, sorry. You'll have to manually map all descendants of Asset Sorry I hadn't spotted that sneaky one. Andy On Thu, Jan 8, 2009 at 3:29 PM, Adriano adriano.mach...@gmail.com wrote: I forgot to mention that I had already set the baseclass to my EntityBase class. On 8 jan, 12:00, Andrew Stewart andrew.stew...@i-nnovate.net wrote: Hi Luis you need to inform automapper that your base type is EntityBase 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(EntityBase); }); Cheers Andy On Thu, Jan 8, 2009 at 1:28 PM, Adriano adriano.mach...@gmail.com wrote: Hi. I'm new to FluentNHibernate / NHibernate, and I would like to ask you guys a question about mapping complex (or deep) inheritance situations. The class hierarchy I have is the following: class Asset : EntityBase { // ... } class Fund : Asset { // ... } class EquityFund : Fund { // ... } class FixedIncomeFund : Fund { // } class Trade : EntityBase { public Asset Asset { get; set; } } I would like to use the AutoMap feature, but NHibernate keep telling me that the class Fund is being duplicated in the mappings. What am I missing? -- = I-nnovate Software - Bespoke Software Development, uk wirral.http://www.i-nnovate.net- Ocultar texto entre aspas - - Mostrar texto entre aspas - -- = 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: Fluent NHibernate and the Windsor NHibernate Integration Facility
I did exactly the same thing, created a custom configuration builder. I have attached it, plus the patch to get the facilities to build. Hope this helps, Chris On Thu, Jan 8, 2009 at 10:48 AM, Tuna Toksöz tehl...@gmail.com wrote: Hmm, What part of castle facility is failing to build? Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Thu, Jan 8, 2009 at 8:42 PM, Sebastien Lambla s...@serialseb.com wrote: I've had to revert to using a SessionManager and manage my sessions myself. Not nice! us --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- CastleNH.patch Description: Binary data using System; using System.Configuration; using System.IO; using System.Reflection; using Castle.Core.Configuration; using Castle.Facilities.NHibernateIntegration.Internal; using FluentNHibernate; using NHibernate.Event; using Configuration=NHibernate.Cfg.Configuration; namespace Framework.NHibernate { public class ConfigurationBuilder : IConfigurationBuilder { private const String nHMappingAttributesAssemblyName = NHibernate.Mapping.Attributes; #region IConfigurationBuilder Members public Configuration GetConfiguration(IConfiguration config) { Configuration configuration = new Configuration(); ApplyConfigurationSettings(configuration, config.Children[settings]); RegisterAssemblies(configuration, config.Children[assemblies]); RegisterResources(configuration, config.Children[resources]); RegisterListeners(configuration, config.Children[listeners]); return configuration; } #endregion /// summary /// Applies the configuration settings. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected static void ApplyConfigurationSettings(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String key = item.Attributes[key]; String value = item.Value; cfg.SetProperty(key, value); } } /// summary /// Registers the resources. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected static void RegisterResources(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String name = item.Attributes[name]; String assembly = item.Attributes[assembly]; if (assembly != null) { cfg.AddResource(name, ObtainAssembly(assembly)); } else { cfg.AddXmlFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name)); } } } /// summary /// Registers the listeners. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected static void RegisterListeners(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String eventName = item.Attributes[event]; String typeName = item.Attributes[type]; if (!Enum.IsDefined(typeof (ListenerType), eventName)) throw new ConfigurationErrorsException(An invalid listener type was specified.); Type classType = Type.GetType(typeName); if (classType == null) throw new ConfigurationErrorsException(The full type name of the listener class must be specified.); ListenerType listenerType = (ListenerType) Enum.Parse(typeof (ListenerType), eventName); object listenerInstance = Activator.CreateInstance(classType); cfg.SetListener(listenerType, listenerInstance); } } /// summary /// Registers the assemblies. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected static void RegisterAssemblies(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; PersistenceModel persistenceModel = new PersistenceModel
[fluent-nhib] Re: Fluent NHibernate and the Windsor NHibernate Integration Facility
FYI, there's a Rake target for switching the binaries. From the trunk/ folder, type rake -T. These tasks are of particular interest: rake nhib21 # Builds Fluent NHibernate against the NHibernate 2.1 lib... rake use_nhib_20 # Switches NHibernate dependencies to NHibernate 2.0 rake use_nhib_21 # Switches NHibernate dependencies to NHibernate 2.1 From: fluent-nhibernate@googlegroups.com on behalf of Chris Bilson Sent: Thu 1/8/2009 1:44 PM To: Fluent NHibernate Subject: [fluent-nhib] Re: Fluent NHibernate and the Windsor NHibernate Integration Facility The 2.1 NH binaries are in the FNH tree. I've just been copying those into the parent directory (where the c# projects get their references) and rebuilding building FNH. I ended up ditching the castle NH facility, after using it for many years. I realized what it does is really pretty simple, so I just built my own Unit of work implementation that handles session management, per request sessions and transactions in web apps, and of course integrating with FNH for configuring session factories. If anyone else is doing this it would be interesting to exchange ideas. On Jan 8, 10:42 am, Sebastien Lambla s...@serialseb.com wrote: No luck with the trunk of castle though as it relies on 2.1 and fluent nhibernate so far seems compiled against 2.0. Is there a way to change that when compiling fluent nhibernate? Or is there a 2.0 compat nhibernate facility in castle? I've had to revert to using a SessionManager and manage my sessions myself. Not nice! -Original Message- From: fluent-nhibernate@googlegroups.com [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of Mike Hadlow Sent: 08 January 2009 17:02 To: Fluent NHibernate Subject: [fluent-nhib] Re: Fluent NHibernate and the Windsor NHibernate Integration Facility Woops, sorry that code above won't work. You have to create you own IConfigurationBuilder. This one is tested and works: /// summary /// Default imlementation of see cref=IConfigurationBuilder/ /// /summary public class FluentNHibernateConfigurationBuilder : IConfigurationBuilder { /// summary /// Builds the Configuration object from the specifed configuration /// /summary /// param name=config/param /// returns/returns public Configuration GetConfiguration(IConfiguration config) { Configuration cfg = new Configuration(); ApplyConfigurationSettings(cfg, config.Children[settings]); cfg.AddMappingsFromAssembly(typeof(Order).Assembly); AdditionalConfiguration(config, cfg); return cfg; } /// summary /// Override this method to provide additional configuration /// /summary /// param name=config/param /// param name=cfg/param public virtual void AdditionalConfiguration(IConfiguration config, Configuration cfg) {} /// summary /// Applies the configuration settings. /// /summary /// param name=cfgThe CFG./param /// param name=facilityConfigThe facility config./param protected void ApplyConfigurationSettings(Configuration cfg, IConfiguration facilityConfig) { if (facilityConfig == null) return; foreach (IConfiguration item in facilityConfig.Children) { String key = item.Attributes[key]; String value = item.Value; cfg.SetProperty(key, value); } } } --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~--- inline: winmail.dat
[fluent-nhib] Re: question on auto mapping
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
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: Fluent NHibernate and the Windsor NHibernate Integration Facility
I agree, Fabio's recent post on the Conversation per business transaction appears to be the absolute 100% dead on way to go for ASP.NET for NH session management. Date: Thu, 8 Jan 2009 21:45:19 +0200 From: tehl...@gmail.com To: fluent-nhibernate@googlegroups.com Subject: [fluent-nhib] Re: Fluent NHibernate and the Windsor NHibernate Integration Facility For session management thing, I advise everybody to take a look at http://fabiomaulo.blogspot.com Tuna Toksöz http://tunatoksoz.com Typos included to enhance the readers attention! On Thu, Jan 8, 2009 at 9:44 PM, Chris Bilson cbil...@gmail.com wrote: built my own Unit of work implementation that handles session _ Windows Live™ Hotmail®: Chat. Store. Share. Do more with mail. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_hm_justgotbetter_explore_012009 --~--~-~--~~~---~--~~ 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: PersistentModel - Make Mappings Property
Hi Chris, I am afraid that in its current state, even if the mappings were publicly accessible, you would struggle to extract all the necessary data from them. It is further complicated by the fact that you would want to access the data AFTER conventions have been applied, but in some cases the conventions only modify the output xml, not the model itself. I would encourage you to pull the source down, change it to public and try working against it - I suspect you will find that this is not quite as simple as making the mappings public. Paul Batum On Fri, Jan 9, 2009 at 5:30 AM, Chris Bilson cbil...@gmail.com wrote: Sorry, subject should be Persist_ence_Model On Jan 8, 10:30 am, Chris Bilson cbil...@gmail.com wrote: Does it make sense to want a public property to access the mappings in a persistent model? I can imagine many uses for this: * I want a DiagnosticMappingVisitor that does not need to write to a folder * I want to do some kind of post processing to the mappings * I want to build scaffolding (like rails style scaffolding) from the metadata in the model This should be very easy to do, I was just wondering if this isn't exposed on purpose. 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 -~--~~~~--~~--~--~---