[fluent-nhib] Re: Adding attributes to elements in Fluent NHibernate mapping classes

2009-02-06 Thread James Gregory

ReadOnly sets those attributes. Checkout
http://wiki.fluentnhibernate.com/show/StandardMappingRelationships

On 2/6/09, Anson Davis  wrote:
> For an NHibernate class element, if there's not a Fluent NHibernate method
> for supporting a given attribute yet, how would you go about adding it to
> your mapping classes?  For example, the many-to-one element has attributes
> like "update" and "insert" that don't appear to be supported by
> IManyToOnePart.
>
> I figured I could just use SetAttribute to accomplish this, but all the
> methods to set attributes have the signature
>
> public void SetAttribute(string name, string value)
>
> Since the return type is "void", you can't really use the method in your
> ClassMap in a fluent way (i.e. chaining).  You could only call the method
> once, and it would have to be the last thing you call, like:
>
> this.References(x => x.SomeClass, "SomeClass_Id")
>  .Not.Nullable()
>  .SetAttribute("update", "false");
>
> Is there another way I should be doing this?
>
> >
>

--~--~-~--~~~---~--~~
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: Having troubles mapping standard aspnet_ tables.

2009-02-08 Thread James Gregory
Your UserPermission.allRoles is an List, when it should be an IList;
that's why you're getting the conversion error.

On Sun, Feb 8, 2009 at 5:27 PM, Pete  wrote:

>
> There are four tables that cover permission.
>
> aspnet_Roles
> aspnet_UsersInRole
> aspnet_User
> aspnet_Membership
>
> These are the standard MS tables.  I plan to just use these tables for
> reading only.   Then use the standard membership routines to modify
> the data.   Mostly I am doing this to test mapping on a set of tables
> everyone has.  My database is express.  I am having problems with the
> many to many
>
> Here are the EO:
>
>
> public class UserRoles
>{
>public virtual Guid RoleId { get; set; }
>public virtual string RoleName { get; set; }
>public virtual IList UserWithRole { get;
> private set; }
>
>public UserRoles()
>{
>UserWithRole = new List();
>}
>
>}
>
>  public class UserPermission
>{
>public virtual Guid UserId { get; private set; }
>public virtual string UserName { get; set; }
>public virtual List allRoles { get; set; }
>public virtual Membership oneMembership { get; private set; }
>
>public virtual void AssignMembership(Membership membership)
>{
>oneMembership = membership;
>membership.Owner = this;
>}
>
>public virtual void AddUserRole(UserRoles userRole)
>{
>userRole.UserWithRole.Add(this);
>allRoles.Add(userRole);
>}
>
>public UserPermission()
>{
>allRoles = new List();
>}
>}
>
> public class Membership
>{
>public virtual Guid UserId { get; set; }
>public virtual string Email { get; set; }
>public virtual bool IsLockedOut { get; set; }
>public virtual bool IsApproved { get; set; }
>public virtual DateTime LastLoginDate { get; set; }
>public virtual UserPermission Owner { get; set; }
>}
>
>
> Here are my mappings
>
>  public class UserRolesMap : ClassMap
>{
>public UserRolesMap()
>{
>Id(x => x.RoleId);
>Map(x => x.RoleName);
>
>
>HasManyToMany(x => x.UserWithRole)
>  .Cascade.All().IsInverse()
>  .WithTableName("[SnapData].[dbo].[aspnet_UsersInRole]");
>
>WithTable("[SnapData].[dbo].[aspnet_Users]");
>}
>}
>
> public class UserPermissionMap : ClassMap
>{
>public UserPermissionMap()
>{
>Id(x => x.UserId);
>Map(x => x.UserName);
>//Map(x => x.LastActivityDate);
>WithTable("[SnapData].[dbo].[aspnet_Users]");
>
>HasManyToMany(x => x.allRoles)
>.Cascade.All()
>.AsBag()
>.WithTableName("[SnapData].[dbo].
> [aspnet_UserInRole]");
>
>HasOne(x => x.oneMembership)
>.PropertyRef(p => p.Owner)
>.Cascade.All()
>.FetchType.Join();
>
>}
>}
>
>  public class MembershipMap : ClassMap
>{
>public MembershipMap()
>{
>Id(x => x.UserId);
>Map(x => x.Email);
>Map(x => x.IsLockedOut);
>Map(x => x.IsApproved);
>Map(x => x.LastLoginDate);
>
>References(x => x.Owner)
>.WithUniqueConstraint()
>.TheColumnNameIs("UserId")
>.LazyLoad()
>.Cascade.None();
>
>WithTable("[SnapData].[dbo].[aspnet_Membership]");
>}
>}
>
> You can tell from the UserPermission mapping that I am mapping one to
> one for aspnet_Membership to aspnet_Users.   I am also mapping many to
> many for aspnet_UserRoles to aspnet_User.  My one to one is working
> fine.   My many to many is not working.   I think it mght have to do
> lack of understanding of List<>  vs bag
>
> Error Message from nUnit:
> _Test_EOMapping.UserPermissionTest.DisplayOneRow:
> NHibernate.PropertyAccessException : The type
> NHibernate.Collection.Generic.PersistentGenericBag`1
> [SnapsInTime.EO.UserRoles] can not be assigned to a property of type
> System.Collections.Generic.List`1[SnapsInTime.EO.UserRoles] setter of
> SnapsInTime.EO.UserPermission.allRoles
>  > System.ArgumentException : Object of type
> 'NHibernate.Collection.Generic.PersistentGenericBag`1
> [SnapsInTime.EO.UserRoles]' cannot be converted to type
> 'System.Collections.Generic.List`1[SnapsInTime.EO.UserRoles]'.
>
> Thanks in advance
> Pete
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-09 Thread James Gregory
Billy, it's important to note that I never said you shouldn't be deriving
from AutoMap. If that works for you (or did...) then great. My point is
that this style of modeling has evolved without my knowledge, which is
interesting and concerning at the same time; if it's a good thing then I
have no issue with it, but I can't be seen to endorse it without
understanding the implications of it's use beforehand.
For starters, we have no tests covering this code; which leads us to
situations like this where I manage to break it for people without ever
knowing. We have no examples promoting this style (unless somebody's written
some I wasn't aware of), and as a result we have no way of supporting this
from a guidance perspective.

My final disagreement with this is that I don't actually like the way it
feels. It looks like a ClassMap, smells like a ClassMap, but is an AutoMap.
You look at it and, unless you already know that it's an AutoMap, think
"where are all the other mappings?" However, that could just be me because
I'd not used it in this manner.

All that being said, I can definitely see the merit in separating the
overrides into their own classes. People obviously like doing overrides in
the manner that #arch does them, so presuming I can get the code under test
(and fix the bug), I have no issue with people proceeding.

I've got some time tomorrow working on FNH, so I'll take a look at this
then.

On Mon, Feb 9, 2009 at 3:16 AM, Billy  wrote:

>
> I was also inheriting from AutoMap and ran into the same exception
> with recent updates.  The workaround that I've put in place for this
> issue for keeping overrides well organized is described at
>
> http://groups.google.com/group/sharp-architecture/msg/c74d493fc74ed988?hl=en
> .
> Although it's within the context of S#arp Architecture, it could be
> reused in any project.
>
> Billy McCafferty
>
>
> On Feb 3, 12:13 pm, Jimit  wrote:
> > The method MergeWithAutoMapsFromAssembly() seemed to suggest the
> > style I used - that is, subclassing AutoMap in an assembly. It did
> > discover  my automaps fine, but then failed with the error described.
> > My domain has some very deep hierarchies and the fluent configuration
> > (using ForTypesThatDeriveFrom) was getting rather wordy so I
> > seperated them into individual subclasses of AutoMap and merged
> > them into my AutoPersistenceModel using
> > MergeWithAutoMapsFromAssembly(). It seemed to work fine, until it
> > didn't.  :) I think subclassing AutoMap  should be supported, if
> > nothing else than for consistency with ClassMap for non-automapped
> > entities.
> >
> > Speaking of ForTypesThatDeriveFrom, I think a non-generic overload
> > might come in handy. One use case (that's got me stumped at the moment
> > - having to use reflection) is setting conventions for the open form
> > of a generic base type, e.g EntityBase<,>. In my particular case, I
> > want to ignore certain properties in EntityBase but don't
> > want to have to tell the Automapper to ignore it for each individual
> > TEntity. Any suggestions?
> > On a side note, you mentioned a check-in adding support for mapping
> > generic base classes
> >
> > On Feb 3, 4:32 pm, James Gregory  wrote:
> >
> > > Hi,
> > > You seem to be correct in your analysis. The reason this is happening
> is
> > > because it was never intended that people would subclass AutoMap;
> > > alterations to classes are supposed to be done in the
> > > ForTypesThatDeriveFrom call on the automapper, rather than in a
> subclass.
> >
> > > I realise this is probably quite annoying, but I'm not willing to
> endorse
> > > this style of automapping until I've done some investigation into it's
> > > implications. For the time being, I'd recommend either altering your
> code to
> > > use the recommended ForTypesThatDeriveFrom call, or altering the code
> > > yourself.
> >
> > > I will make a note to review this style to see if it's something we
> should
> > > officially support.
> >
> > > James
> >
> > > On Tue, Feb 3, 2009 at 4:25 PM, Jimit  wrote:
> >
> > > > Hi,
> > > > Sorry if this comes as a duplicate post. I think google might have
> > > > eaten my first so here it is again.
> > > > First off, mad props to all of you involved in the FNH - it rocks!
> > > > That said, I've come across what seems to be abugin the method
> > > > FindMapping of the AutoPersistenceModel class. Here's a sample
> > > > stack trace:
&

[fluent-nhib] Re: AutoMapping / Components

2009-02-09 Thread James Gregory
>
> Should AutoMap.Component return down to Auto map for the component
>
instead of just map so I don't need to have my redundant mappings


I'm not quite sure what you mean here Chris.

 In the second one for  is there anyway I can reach back up to
>
convention.GetComponentColumnPrefix = type => string.Empty;


There's not, but you could specify your convention to be something like
this:

convention.GetComponentColumnPrefix = property =>
{
  if (property.PropertyType == typeof(Address) && property.DeclaringType ==
typeof(Order))
return "Ship";
  else
return property.PropertyType.Name;
};

that's from memory, so it may not be exact, but you'd check the type that
the property is declared in to see if it's Order, then override the column
prefix.

On Sun, Feb 8, 2009 at 9:59 PM, Chris Marisic  wrote:

>
> In my AutoPersistanceModel setup I have this in my mapping
>
> .ForTypesThatDeriveFrom(autoMap =>
>{
>autoMap.Id(p =>
> p.Id).GeneratedBy.Assigned().SetAttribute("length", "5");
>autoMap.Map(p =>
> p.CompanyName).Not.Nullable();
>autoMap.Component(p
> => p.Address, addr =>
>
> {
>
> addr.Map(c => c.Street, "Address");
>
> addr.Map(c => c.State, "Region");
>
> addr.Map(c => c.City, "City");
>
> addr.Map(c => c.Country, "Country");
>
> addr.Map(c => c.PostalCode, "PostalCode");
>
>   });
>})
> .ForTypesThatDeriveFrom(autoMap =>
> {
> autoMap.References(p =>
> p.ShipVia, "ShipVia");
> autoMap.Component(p =>
> p.Address, addr =>
>
> {
>
> addr.Map(c => c.Street, "ShipAddress");
>
> addr.Map(c => c.State, "ShipRegion");
>
> addr.Map(c => c.City, "ShipCity");
>
> addr.Map(c => c.Country, "ShipCountry");
>
> addr.Map(c => c.PostalCode, "ShipPostalCode");
>
>});
>
> })
>
> })
>
> Should AutoMap.Component return down to Auto map for the component
> instead of just map so I don't need to have my redundant mappings
>
> addr.Map(x => x.City, "City");
> addr.Map(x => x.Country, "Country");
>
> In the second one for  is there anyway I can reach back up to
> convention.GetComponentColumnPrefix = type => string.Empty;
>
> That I change that convention ForTypesThatDeriveFrom to "Ship" ?
> >
>

--~--~-~--~~~---~--~~
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: Mapping simple datatypes via fluent nhibernate

2009-02-09 Thread James Gregory

HasMany(x => x.MyListOfStrings)
  .WithElement("string column name")

This is from memory so it may not be exact.

On 2/9/09, Tom Warnat  wrote:
>
> Hi,
>
> i've tryed to map a list of string via fluent nhibernate lately and i
> can't get it to run.
>
> So googling for 8 hours on friday i'll take my shoot here.
>
> Can anyone tell me to map a simply a List? Furthermore how get
> fluent nhibernate to automatically create the relation for the list
> (which is basically my problem)?
>
> thanks in advance.
>
> >
>

--~--~-~--~~~---~--~~
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: Having troubles mapping standard aspnet_ tables.

2009-02-09 Thread James Gregory

Is there a reason you're using the full database.schema.table format?
Have you tried just specifying the table name?

On 2/9/09, Pete  wrote:
>
> James,  thanks for the quick response.   The IList fix the problem.
> But I am still having issues with the collections.   I am now getting
> this error message
>
> _Test_EOMapping.UserPermissionTest.DisplayOneRow:
> NHibernate.Exceptions.GenericADOException : could not initialize a
> collection: [SnapsInTime.EO.UserPermission.allRoles#ab68b9ac-f2e5-4147-
> a143-00a405d47e39][SQL: SELECT allroles0_.UserPermission_id as
> UserPerm1_1_, allroles0_.UserRoles_id as UserRoles2_1_,
> userroles1_.RoleId as RoleId1_0_, userroles1_.RoleName as RoleName1_0_
> FROM [SnapData].[dbo].[aspnet_UsersInRole] allroles0_ left outer join
> [SnapData].[dbo].[aspnet_Users] userroles1_ on
> allroles0_.UserRoles_id=userroles1_.RoleId WHERE
> allroles0_.UserPermission_id=?]
>   > System.Data.SqlClient.SqlException : Invalid object name
> 'SnapData.dbo.aspnet_UsersInRole'.
>
> On Feb 8, 2:24 pm, James Gregory  wrote:
>> Your UserPermission.allRoles is an List, when it should be an IList;
>> that's why you're getting the conversion error.
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
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: Having troubles mapping standard aspnet_ tables.

2009-02-09 Thread James Gregory

I'd say that issue is still affecting you then, because that exception
is saying it can't find the table.

Have you investigated this issue much? Sounds like it's either
something wrong with your connection string or the priviledges for the
user you're connecting as.

On 2/9/09, Pete  wrote:
>
> Yes,   if I just specify the the table name,  sometimes the DB likes
> me and will find the table other times it will not like me and tell me
> the table is not found.   I get this with linq-sql  too.   This is not
> a fluent issue.  Therefore if I specify the full db.schema.table  I do
> not have an issue about access.
>
>
> On Feb 9, 7:43 am, James Gregory  wrote:
>> Is there a reason you're using the full database.schema.table format?
>> Have you tried just specifying the table name?
>>
>> On 2/9/09, Pete  wrote:
>>
>>
>>
>>
>>
>> > James,  thanks for the quick response.   The IList fix the problem.
>> > But I am still having issues with the collections.   I am now getting
>> > this error message
>>
>> > _Test_EOMapping.UserPermissionTest.DisplayOneRow:
>> > NHibernate.Exceptions.GenericADOException : could not initialize a
>> > collection: [SnapsInTime.EO.UserPermission.allRoles#ab68b9ac-f2e5-4147-
>> > a143-00a405d47e39][SQL: SELECT allroles0_.UserPermission_id as
>> > UserPerm1_1_, allroles0_.UserRoles_id as UserRoles2_1_,
>> > userroles1_.RoleId as RoleId1_0_, userroles1_.RoleName as RoleName1_0_
>> > FROM [SnapData].[dbo].[aspnet_UsersInRole] allroles0_ left outer join
>> > [SnapData].[dbo].[aspnet_Users] userroles1_ on
>> > allroles0_.UserRoles_id=userroles1_.RoleId WHERE
>> > allroles0_.UserPermission_id=?]
>> >   > System.Data.SqlClient.SqlException : Invalid object name
>> > 'SnapData.dbo.aspnet_UsersInRole'.
>>
>> > On Feb 8, 2:24 pm, James Gregory  wrote:
>> >> Your UserPermission.allRoles is an List, when it should be an
>> >> IList;
>> >> that's why you're getting the conversion error.- Hide quoted text -
>>
>> - Show quoted text -
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-09 Thread James Gregory
> elsewhere. However, I think some smart naming conventions, namespacing,
> and
> > a little bit of education could go a long way toward eliminating that
> > concern. But then, that's just my opinion.
> >
> > Perhaps talking about the various ways folks are using FNH mappings (both
> > auto and manual), and the lessons we're learning, would be a good topic
> for
> > a VAN Meeting?
> >
> > -steve
> >
> > //  90% of being smart is knowing what you're dumb at  //
> http://stevenharman.net/
> >
> > On Mon, Feb 9, 2009 at 9:44 AM, AndyStewart  >wrote:
> >
> >
> >
> > > Hi James
> >
> > > I've not read the whole thread, so forgive me if I'm going in the
> > > wrong direction. However let me shed some light on this,
> > > looks like some users of the library are inheriting from AutoMap and
> > > using the model.addMappingsFromAssembly(  ); method.
> > > This is in-fact the very first way I wrote automappings, until Chad
> > > showed me the light to the fluent method. However if
> > > your doing alot of custom mappins then loading in via seperate classes
> > > is a lot cleaner than the 80 lins of fluent code
> > > I have in one of my projects (yuk).
> >
> > > Hope you this puts you in the picture as how this has come about.
> >
> > > Andy
> >
> > > On Feb 9, 10:33 am, James Gregory  wrote:
> > > > Billy, it's important to note that I never said you shouldn't be
> deriving
> > > > from AutoMap. If that works for you (or did...) then great. My
> point
> > > is
> > > > that this style of modeling has evolved without my knowledge, which
> is
> > > > interesting and concerning at the same time; if it's a good thing
> then I
> > > > have no issue with it, but I can't be seen to endorse it without
> > > > understanding the implications of it's use beforehand.
> > > > For starters, we have no tests covering this code; which leads us to
> > > > situations like this where I manage to break it for people without
> ever
> > > > knowing. We have no examples promoting this style (unless somebody's
> > > written
> > > > some I wasn't aware of), and as a result we have no way of supporting
> > > this
> > > > from a guidance perspective.
> >
> > > > My final disagreement with this is that I don't actually like the way
> it
> > > > feels. It looks like a ClassMap, smells like a ClassMap, but is an
> > > AutoMap.
> > > > You look at it and, unless you already know that it's an AutoMap,
> think
> > > > "where are all the other mappings?" However, that could just be me
> > > because
> > > > I'd not used it in this manner.
> >
> > > > All that being said, I can definitely see the merit in separating the
> > > > overrides into their own classes. People obviously like doing
> overrides
> > > in
> > > > the manner that #arch does them, so presuming I can get the code
> under
> > > test
> > > > (and fix the bug), I have no issue with people proceeding.
> >
> > > > I've got some time tomorrow working on FNH, so I'll take a look at
> this
> > > > then.
> >
> > > > On Mon, Feb 9, 2009 at 3:16 AM, Billy  wrote:
> >
> > > > > I was also inheriting from AutoMap and ran into the same exception
> > > > > with recent updates.  The workaround that I've put in place for
> this
> > > > > issue for keeping overrides well organized is described at
> >
> > > > >
> http://groups.google.com/group/sharp-architecture/msg/c74d493fc74ed98.
> > > ..
> > > > > .
> > > > > Although it's within the context of S#arp Architecture, it could be
> > > > > reused in any project.
> >
> > > > > Billy McCafferty
> >
> > > > > On Feb 3, 12:13 pm, Jimit  wrote:
> > > > > > The method MergeWithAutoMapsFromAssembly() seemed to suggest
> the
> > > > > > style I used - that is, subclassing AutoMap in an assembly. It
> did
> > > > > > discover  my automaps fine, but then failed with the error
> described.
> > > > > > My domain has some very deep hierarchies and the fluent
> configuration
> > > > > > (using ForTypesThatDeriveFrom) was getting rather wordy so I
> >

[fluent-nhib] Re: Any plans to support for nhibernate filters?

2009-02-09 Thread James Gregory
Any filters in particular? Class level? Collection level? If just filters in
general, then this is a big change.

On Mon, Feb 9, 2009 at 4:01 PM, Will A  wrote:

>
> Are there any plans to offer support for nhibernate filters in the
> near future?  I need to use filters for a piece of functionality I am
> working on, and for the time being have had to drop back to xml
> mappings for the classes that need filters applied (which is a pain).
>
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-09 Thread James Gregory
One for each then, thanks guys! :)

On Mon, Feb 9, 2009 at 9:28 PM, Steven Harman  wrote:

> Seeing this new way, I think I'd much prefer it to using inheritance. I've
> really started to realize that inheritance is rarely the optimal solution to
> a problem - often its simply the one we are most comfy with, and so we
> naturally go there first.
>
> So, I guess what I'm saying is... I'd rather see the extension method way,
> as it adds a nice point of extension, while allowing us to leverage
> composition to build really dynamic and granular mapping overrides. Or at
> least, that's my gut reaction.
>
> Thanks all,
> -steve
>
> //  90% of being smart is knowing what you're dumb at  //
> http://stevenharman.net/
>
>
> On Mon, Feb 9, 2009 at 3:27 PM, Billy  wrote:
>
>>
>> James,
>>
>> Thank you for my input on the matter; albeit, I'd like it to be
>> perfectly known that I'm still getting my feet wet with Fluent
>> NHibernate and have a lot to learn on the subject.  Personally, I like
>> the ability to inherit from AutoMap as it makes the behavior more
>> interchangeable with ClassMap behavior.  It also makes the mapping
>> identical in nature to that of ClassMap without having to introduce
>> lambdas, which I see as complicating the matter, if only slightly.
>> Finally, it makes it easier to use inheritance to create a grouping of
>> overridden mappings.  For instance, suppose you want an
>> AuditableAutoMap<> base class which inherits from AutoMap<> and
>> overrides a number of conventions for any entity that is IAuditable.
>> You could than have a concrete MyEntityMapClass which inherits from
>> AuditableAutoMap<>, one for each IAuditable entity.  This would allow
>> you to create an "override group" if you will.
>>
>> With that said, there are other approaches that could be taken to
>> simulate on override grouping via encapsulation rather than via
>> inheritance.  But it's nice to have the inheritance option, if only
>> for organization and consistency with ClassMap. :D  When it comes down
>> to it, there are decisions that must be made for the integrity of the
>> design; if you feel that avoiding AutoMap inheritance is in the best
>> interest of the overall design of Fluent NHibernate, then I'm very
>> supportive of that decision as well.
>>
>> Thanks for all your great work on Fluent NHibernate...it's been a big
>> hit within S#arp Architecture.
>>
>> Billy McCafferty
>>
>>
>> On Feb 9, 1:07 pm, James Gregory  wrote:
>> > I think what I've been saying may have been interpreted as being more
>> > negative or hostile than I intended it to be. My basic point was, there
>> > isn't a bug because you aren't using a "feature" of FNH.
>> > I'm happy for this to become a proper supported way of overriding
>> > automappings, but for me to be expected to support it I have to actually
>> > write coverage for it. Until I do that, it's unofficial.
>> >
>> > As for my stance on actually using it, as long as it's explained that
>> they
>> > are overrides (and as Steve said, with a decent naming convention)
>> there's
>> > nothing wrong with inheriting from AutoMap. I'm all for SoC.
>> >
>> > Billy: do you prefer your new way of writing the overrides, or would you
>> > prefer to just inherit from AutoMap? Is this new way just to avoid the
>> bug?
>> >
>> > What I'm saying is: say the word and I'll make this an official feature;
>> > then I won't moan about not supporting an unofficial feature.
>> >
>> > On Mon, Feb 9, 2009 at 7:29 PM, Billy  wrote:
>> >
>> > > Here's the final approach that I took to organize my overrides:
>> >
>> > > 1) Add an override interface to your application as follows:
>> >
>> > > using FluentNHibernate.AutoMap;
>> >
>> > > namespace SharpArch.Data.NHibernate.FluentNHibernate
>> > > {
>> > >/// 
>> > >/// Used by  to add
>> > > auto mapping overrides
>> > >/// to 
>> > >/// 
>> > >public interface IAutoPeristenceModelConventionOverride
>> > >{
>> > >AutoPersistenceModel Override(AutoPersistenceModel model);
>> > >}
>> > > }
>> >
>> > > 2) Create an extension method, as follows, to look for every class
&

[fluent-nhib] Re: Urgence:How to map this situation?

2009-02-09 Thread James Gregory
Hey Levin, I've just committed a change that should hopefully fix this
problem for you. Let me know how it works out.

On Thu, Feb 5, 2009 at 1:40 PM, Levin  wrote:

>
> Expect for that:)
>
> On Feb 5, 8:10 pm, James Gregory  wrote:
> > Support for using variables in a where clause isn't implemented, as the
> > exception says.
> > I'll put this on my list of things todo.
> >
> > On Thu, Feb 5, 2009 at 11:49 AM, Levin  wrote:
> >
> > >It says NotImplementedException:
> > >--TargetInvocationException
> > >at System.RuntimeMethodHandle._InvokeConstructor(Object[] args,
> > > SignatureStruct& signature, IntPtr declaringType)
> > >at System.RuntimeMethodHandle.InvokeConstructor(Object[] args,
> > > SignatureStruct signature, RuntimeTypeHandle declaringType)
> > >at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags
> > > invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
> > >at System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
> > >at
> > >
> FluentNHibernate.TypeExtensions.InstantiateUsingParameterlessConstructor
> > > (Type type)
> > >at
> > > FluentNHibernate.PersistenceModel.addMappingsFromAssembly(Assembly
> > > assembly)
> > >F:\7Garden\Documents\Visual Studio 2008\Projects\LevinCastle\src
> > > \dafenbei\Dafenbei.Core.Test\TestModel.cs(16,0): 在
> > > Dafenbei.Core.Test.TestModel..ctor()
> > >--NotImplementedException
> > >at FluentNHibernate.ExpressionToSql.Convert(Expression
> expression)
> > >at FluentNHibernate.ExpressionToSql.Convert(BinaryExpression
> > > expression)
> > >at FluentNHibernate.ExpressionToSql.Convert[T](Expression`1
> > > expression)
> > >at FluentNHibernate.Mapping.ToManyBase`3.Where(Expression`1
> where)
> >
> > > On Feb 4, 5:22 pm, James Gregory  wrote:
> > > > Care to share what the exception is?
> >
> > > > On Wed, Feb 4, 2009 at 9:10 AM, Levin  wrote:
> >
> > > > > Well,the where clause works nicely,but there's a strange issue...
> > > > > I do as below in my PostMap class,it throws exception in my unit
> test
> > > > >public PostMap() {
> > > > >...
> > > > > HasMany(x=>x.Comments)
> > > > > .WithKeyColumn("ObjID")
> > > > >.Where(x => x.ObjType == CommentTypes.Post.ToString
> > > > > ());
> > > > >}
> >
> > > > > When i change to below,everything goes well:
> > > > > HasMany(x=>x.Comments)
> > > > > .WithKeyColumn("ObjID")
> > > > >.Where(x => x.ObjType == "Post");
> >
> > > > > On Jan 30, 8:44 pm, Levin  wrote:
> > > > > > Thanks for your help,i will make a try tonight,and post my
> response
> > > > > > here later on:)
> > > > > > Thanks again!
> >
> > > > > > On Jan 30, 5:21 am, James Gregory 
> wrote:
> >
> > > > > > > Well, the Where statement is now mapped.
> > > > > > > If ObjType is in your class (and you are using the default
> column
> > > name)
> > > > > you
> > > > > > > can do this:
> >
> > > > > > > HasMany(x => x.Comments)
> > > > > > >   .Where(x => x.ObjType == "Product");
> >
> > > > > > > If it isn't in your object, or it is but the name differs from
> the
> > > > > database
> > > > > > > column, then you should do this instead:
> >
> > > > > > > HasMany(x => x.Comments)
> > > > > > >   .Where("ObjType = 'Product'");
> >
> > > > > > > On Wed, Jan 28, 2009 at 12:36 PM, James Gregory <
> > > > > jagregory@gmail.com>wrote:
> >
> > > > > > > > I'm not entirely sure how you'dmapthis using standard hbm,
> but I
> > > > > think
> > > > > > > > it'd probably involve the where attribute on the collection.
> We
> > > > > currently
> > > > > > > > don't explicitly support where, so you'll have to fud

[fluent-nhib] Re: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-09 Thread James Gregory
Well, I'm torn.
I've just knocked together a prototype for what is essentially Billy's
design, reworked a bit.
I've created an IAutoMappingConfigChunk, which has an
Configure(AutoPersistenceModel model) method. You add chunks to an APM, each
one gets executed before the mappings are compiled.

Leading on from that, I've created an IMappingOverride interface, which
has a single method of Override(AutoMap mapping); this interface allows
you to have the simplicity of class-per-override as the inheritance
strategy, but without the nasty inheritance.

IMappingOverride's are added using a custom IAutoMappingConfigChunk that
takes an assembly and finds any types that derive from IMappingOverride. So
i'm actually dogfooding the config stuff.

http://gist.github.com/61092 - config chunk stuff
http://gist.github.com/61097 - IMappingOverride stuff

What do you guys think?

On Mon, Feb 9, 2009 at 9:36 PM, Steven Harman  wrote:

> Just doing my part to keep everyone thoroughly confused and confounded! :)
>
> //  90% of being smart is knowing what you're dumb at  //
> http://stevenharman.net/
>
>
> On Mon, Feb 9, 2009 at 4:34 PM, James Gregory wrote:
>
>> One for each then, thanks guys! :)
>>
>>
>> On Mon, Feb 9, 2009 at 9:28 PM, Steven Harman wrote:
>>
>>> Seeing this new way, I think I'd much prefer it to using inheritance.
>>> I've really started to realize that inheritance is rarely the optimal
>>> solution to a problem - often its simply the one we are most comfy with, and
>>> so we naturally go there first.
>>>
>>> So, I guess what I'm saying is... I'd rather see the extension method
>>> way, as it adds a nice point of extension, while allowing us to leverage
>>> composition to build really dynamic and granular mapping overrides. Or at
>>> least, that's my gut reaction.
>>>
>>> Thanks all,
>>> -steve
>>>
>>> //  90% of being smart is knowing what you're dumb at  //
>>> http://stevenharman.net/
>>>
>>>
>>> On Mon, Feb 9, 2009 at 3:27 PM, Billy  wrote:
>>>
>>>>
>>>> James,
>>>>
>>>> Thank you for my input on the matter; albeit, I'd like it to be
>>>> perfectly known that I'm still getting my feet wet with Fluent
>>>> NHibernate and have a lot to learn on the subject.  Personally, I like
>>>> the ability to inherit from AutoMap as it makes the behavior more
>>>> interchangeable with ClassMap behavior.  It also makes the mapping
>>>> identical in nature to that of ClassMap without having to introduce
>>>> lambdas, which I see as complicating the matter, if only slightly.
>>>> Finally, it makes it easier to use inheritance to create a grouping of
>>>> overridden mappings.  For instance, suppose you want an
>>>> AuditableAutoMap<> base class which inherits from AutoMap<> and
>>>> overrides a number of conventions for any entity that is IAuditable.
>>>> You could than have a concrete MyEntityMapClass which inherits from
>>>> AuditableAutoMap<>, one for each IAuditable entity.  This would allow
>>>> you to create an "override group" if you will.
>>>>
>>>> With that said, there are other approaches that could be taken to
>>>> simulate on override grouping via encapsulation rather than via
>>>> inheritance.  But it's nice to have the inheritance option, if only
>>>> for organization and consistency with ClassMap. :D  When it comes down
>>>> to it, there are decisions that must be made for the integrity of the
>>>> design; if you feel that avoiding AutoMap inheritance is in the best
>>>> interest of the overall design of Fluent NHibernate, then I'm very
>>>> supportive of that decision as well.
>>>>
>>>> Thanks for all your great work on Fluent NHibernate...it's been a big
>>>> hit within S#arp Architecture.
>>>>
>>>> Billy McCafferty
>>>>
>>>>
>>>> On Feb 9, 1:07 pm, James Gregory  wrote:
>>>> > I think what I've been saying may have been interpreted as being more
>>>> > negative or hostile than I intended it to be. My basic point was,
>>>> there
>>>> > isn't a bug because you aren't using a "feature" of FNH.
>>>> > I'm happy for this to become a proper supported way of overriding
>>>> > automappings, but for me to be expected to support it I have to

[fluent-nhib] Re: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-10 Thread James Gregory
What's wrong with the chunk? naming?

On Tue, Feb 10, 2009 at 10:49 AM, Jimit  wrote:

>
> +1 for the IMappingOverrides option. I ended up doing something pretty
> similar that works pretty well so far.:
>
> public AutoPersistenceModel ApplyMappingOverridesFromAssembly(this
> AutoPersistenceModel)
> {
>
>IEnumerable mappingOverrides =
> from type in
> typeof(T).Assembly.GetTypes()
> where
> type.IsSubClassOf(typeof (IMappingOverride<>))
> from method in
> type.GetMethods()
> where
> method.DeclaringType == type
>   &&
> method.ReturnType == typeof (void)
>   &&
> method.GetParameters().Count() == 1 &&
>
> method.GetParameters()[0].ParameterType.
>
> GetGenericTypeDefinition() ==
>   typeof
> (AutoMap<>)
> select method;
>mappingOverrides.ForEach(method =>
>   {
>   var entityType =
>   method.GetParameters()
> [0].ParameterType.GetGenericArguments()[0];
>   var autoMapType = typeof
> (AutoMap<>).MakeGenericType(new[] {entityType});
>   var actionType = typeof
> (Action<>).MakeGenericType(new[] {autoMapType});
>   var mappingAction = new[]
> {Delegate.CreateDelegate(actionType, method)};
>
> InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments(
>   model,
>   map =>
> map.ForTypesThatDeriveFrom(null),
>   mappingAction,
>   entityType);
>   });
>return model;
> }
>
> Not too crazy about the IAutoMappingConfigChunk though.
>
> On Feb 10, 12:15 am, Billy  wrote:
> > That strategy works for me.
> >
> > Thank you for being accommodating a viable approach to organizing
> > overrides.
> >
> > Billy
> >
> > On Feb 9, 4:37 pm, James Gregory  wrote:
> >
> > > Well, I'm torn.
> > > I've just knocked together a prototype for what is essentially Billy's
> > > design, reworked a bit.
> > > I've created an IAutoMappingConfigChunk, which has an
> > > Configure(AutoPersistenceModel model) method. You add chunks to an APM,
> each
> > > one gets executed before the mappings are compiled.
> >
> > > Leading on from that, I've created an IMappingOverride interface,
> which
> > > has a single method of Override(AutoMap mapping); this interface
> allows
> > > you to have the simplicity of class-per-override as the inheritance
> > > strategy, but without the nasty inheritance.
> >
> > > IMappingOverride's are added using a custom IAutoMappingConfigChunk
> that
> > > takes an assembly and finds any types that derive from
> IMappingOverride. So
> > > i'm actually dogfooding the config stuff.
> >
> > >http://gist.github.com/61092-config chunk stuffhttp://
> gist.github.com/61097-IMappingOverride stuff
> >
> > > What do you guys think?
> >
> > > On Mon, Feb 9, 2009 at 9:36 PM, Steven Harman 
> wrote:
> > > > Just doing my part to keep everyone thoroughly confused and
> confounded! :)
> >
> > > > //  90% of being smart is knowing what you're dumb at  //
> > > >http://stevenharman.net/
> >
> > > > On Mon, Feb 9, 2009 at 4:34 PM, James Gregory <
> jagregory@gmail.com>wrote:
> >
> > > >> One for each then, thanks guys! :)
> >
> > > >> On Mon, Feb 9, 2009 at 9:28 PM, Steven Harman <
> stevehar...@gmail.com>wrote:
> >
> > > >>> Seeing this new way, I think I'd much prefer it to using
> inheritance.
> > > >>> I've really started to realize that inheritance is rarely the
> optimal
> > > >>> solution to a problem - often its simply the one we are most comfy
> with, and
> > > >>> so we naturally go there first.
&

[fluent-nhib] Re: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-10 Thread James Gregory
...and there's me thinking chunk was an amusing name ;)
ConfigPart, Configurer, Config, ConfigUnit, any ideas?

On Tue, Feb 10, 2009 at 11:47 AM, Jimit  wrote:

>
> That's it. :)
>
> On Feb 10, 11:19 am, James Gregory  wrote:
> > What's wrong with the chunk? naming?
> >
> > On Tue, Feb 10, 2009 at 10:49 AM, Jimit  wrote:
> >
> > > +1 for the IMappingOverrides option. I ended up doing something pretty
> > > similar that works pretty well so far.:
> >
> > > public AutoPersistenceModel ApplyMappingOverridesFromAssembly(this
> > > AutoPersistenceModel)
> > > {
> >
> > >IEnumerable mappingOverrides =
> > > from type in
> > > typeof(T).Assembly.GetTypes()
> > > where
> > > type.IsSubClassOf(typeof (IMappingOverride<>))
> > > from method in
> > > type.GetMethods()
> > > where
> > > method.DeclaringType == type
> > >   &&
> > > method.ReturnType == typeof (void)
> > >   &&
> > > method.GetParameters().Count() == 1 &&
> >
> > > method.GetParameters()[0].ParameterType.
> >
> > > GetGenericTypeDefinition() ==
> > >   typeof
> > > (AutoMap<>)
> > > select method;
> > >mappingOverrides.ForEach(method =>
> > >   {
> > >   var entityType =
> > >   method.GetParameters()
> > > [0].ParameterType.GetGenericArguments()[0];
> > >   var autoMapType = typeof
> > > (AutoMap<>).MakeGenericType(new[] {entityType});
> > >   var actionType = typeof
> > > (Action<>).MakeGenericType(new[] {autoMapType});
> > >   var mappingAction = new[]
> > > {Delegate.CreateDelegate(actionType, method)};
> >
> > > InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments(
> > >   model,
> > >   map =>
> > > map.ForTypesThatDeriveFrom(null),
> > >       mappingAction,
> > >   entityType);
> > >   });
> > >return model;
> > > }
> >
> > > Not too crazy about the IAutoMappingConfigChunk though.
> >
> > > On Feb 10, 12:15 am, Billy  wrote:
> > > > That strategy works for me.
> >
> > > > Thank you for being accommodating a viable approach to organizing
> > > > overrides.
> >
> > > > Billy
> >
> > > > On Feb 9, 4:37 pm, James Gregory  wrote:
> >
> > > > > Well, I'm torn.
> > > > > I've just knocked together a prototype for what is essentially
> Billy's
> > > > > design, reworked a bit.
> > > > > I've created an IAutoMappingConfigChunk, which has an
> > > > > Configure(AutoPersistenceModel model) method. You add chunks to an
> APM,
> > > each
> > > > > one gets executed before the mappings are compiled.
> >
> > > > > Leading on from that, I've created an IMappingOverride
> interface,
> > > which
> > > > > has a single method of Override(AutoMap mapping); this interface
> > > allows
> > > > > you to have the simplicity of class-per-override as the inheritance
> > > > > strategy, but without the nasty inheritance.
> >
> > > > > IMappingOverride's are added using a custom IAutoMappingConfigChunk
> > > that
> > > > > takes an assembly and finds any types that derive from
> > > IMappingOverride. So
> > > > > i'm actually dogfooding the config stuff.
> >
> > > > >http://gist.github.com/61092-configchunk stuffhttp://
> > > gist.github.com/61097-IMappingOverride stuff
> >
> > > > > What do you gu

[fluent-nhib] Re: Obscure Mapping Error

2009-02-10 Thread James Gregory
Can we see how you're setting your conventions and where you're plumbing FNH
into NHibernate?

On Tue, Feb 10, 2009 at 12:01 PM, Jimit  wrote:

>
> I get the following error when attempting to test my mappings:
>
> 
>  lazy="true" assembly="Core.Common" namespace="Core.Common.Entities">
>   xmlns="urn:nhibernate-mapping-2.2">
>
> name="Version" />
>  
> 
>
> System.Xml.Schema.XmlSchemaValidationException: The element 'class' in
> namespace 'urn:nhibernate-mapping-2.2' has invalid child element
> 'version' in namespace 'urn:nhibernate-mapping-2.2'. List of possible
> elements expected: 'id, composite-id' in namespace 'urn:nhibernate-
> mapping-2.2'.
> -- Exception doesn't have a stack trace --
> NHibernate.MappingException: (XmlDocument)(5,6): XML validation error:
> The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has
> invalid child element 'version' in namespace 'urn:nhibernate-
> mapping-2.2'. List of possible elements expected: 'id, composite-id'
> in namespace 'urn:nhibernate-mapping-2.2'.
> at NHibernate.Cfg.Configuration.LogAndThrow(Exception exception)
> at NHibernate.Cfg.Configuration.ValidationHandler(Object o,
> ValidationEventArgs args)
> at System.Xml.Schema.XmlSchemaValidator.SendValidationEvent
> (ValidationEventHandler eventHandler, Object sender,
> XmlSchemaValidationException e, XmlSeverityType severity)
> at System.Xml.Schema.XmlSchemaValidator.ElementValidationError
> (XmlQualifiedName name, ValidationState context,
> ValidationEventHandler eventHandler, Object sender, String sourceUri,
> Int32 lineNo, Int32 linePos, Boolean getParticles)
> at System.Xml.Schema.XmlSchemaValidator.ValidateElementContext
> (XmlQualifiedName elementName, ref Boolean invalidElementInContext)
> at System.Xml.Schema.XmlSchemaValidator.ValidateElement(String
> localName, String namespaceUri, XmlSchemaInfo schemaInfo, String
> xsiType, String xsiNil, String xsiSchemaLocation, String
> xsiNoNamespaceSchemaLocation)
> at System.Xml.XsdValidatingReader.ProcessElementEvent()
> at System.Xml.XsdValidatingReader.ProcessReaderEvent()
> at System.Xml.XsdValidatingReader.Read()
> at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
> at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
> at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
> Boolean preserveWhitespace)
> at System.Xml.XmlDocument.Load(XmlReader reader)
> at NHibernate.Cfg.Configuration.LoadMappingDocument(XmlReader
> hbmReader, String name)
> at NHibernate.Cfg.Configuration.AddXmlReader(XmlReader hbmReader,
> String name)
> at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream,
> String name)
> at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String
> name)
> at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc)
> at FluentNHibernate.MappingVisitor.AddMappingDocument(XmlDocument
> document, Type type)
> at FluentNHibernate.Mapping.ClassMap`1.ApplyMappings(IMappingVisitor
> visitor)
> System.ApplicationException: Error while trying to build the Mapping
> Document for 'Core.Common.Entities.DomainObject'
> at FluentNHibernate.Mapping.ClassMap`1.ApplyMappings(IMappingVisitor
> visitor)
> at FluentNHibernate.PersistenceModel.<>c__DisplayClass1.b__0
> (IMapping mapping)
> at System.Collections.Generic.List`1.ForEach(Action`1 action)
> at FluentNHibernate.PersistenceModel.Configure(Configuration
> configuration)
> at FluentNHibernate.AutoMap.AutoPersistenceModel.Configure
> (Configuration configuration)
> at FluentNHibernate.Cfg.AutoMappingsContainer.Apply(Configuration cfg)
> at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
> at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or
> incomplete configuration was used while creating a SessionFactory.
> Check PotentialReasons collection, and InnerException for more detail.
>
>
> at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
> at Core.Infrastructure.Data.NHibernate.Tests.PersistenceTests.SetUp()
> in PersistenceTests.cs: line 21
>
> DomainObject is marked as a base class in Conventions.IsBaseClass so
> I'm not sure why it's even creating a mapping for it. Essentially it
> contains some common functionality for both entities and value objects
> in my domain. I'm ignoring almost all it's properties in the mapping
> override except for the Version property which I've mapped as readonly
> with access through a Pascal-case field prefixed with underscore.
> The xml schema validation seems to be expecting an Id mapping as the
> first child to  but DomainObject doesn't have one.
> >
>

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

[fluent-nhib] Re: Auto Mapper alter default string column to varchar

2009-02-10 Thread James Gregory
Checkout the DescriptionTypeConvetion in
http://wiki.fluentnhibernate.org/show/AutoMappingTypeConventions

On Tue, Feb 10, 2009 at 1:07 PM, Pezza  wrote:

>
> Hi
>
> Just got everything rocking and rolling with the AutoMapper after some
> "ID" related problems. I would like to map all my "string" properties
> to varchar(x) columns and not nvarchar.
>
> Have looked at ITypeConvention and .WithConvention but can't see the
> obvious place to override this setting.
>
> Any help greatly appreciated.
>
>
> >
>

--~--~-~--~~~---~--~~
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: Auto Mapper alter default string column to varchar

2009-02-10 Thread James Gregory
CustomSqlTypeIs should work, or CustomTypeIs.

On Tue, Feb 10, 2009 at 1:20 PM, Pezza  wrote:

>
> Tried setting the withLengthOf() and that doesn't change the type of
> the column.
> Also tried customsqltypeis and that doesn't seem to have any effect.
>
> Also cant find anything on the IProperty to change the column type.
>
> Tried looking for "nvarchar" in the FluentNhibernate source and
> nothing found there either.
>
> Sorry to be a pain, any other pointers?
>
> Mark
>
> On Feb 10, 1:16 pm, James Gregory  wrote:
> > Checkout the DescriptionTypeConvetion inhttp://
> wiki.fluentnhibernate.org/show/AutoMappingTypeConventions
> >
> > On Tue, Feb 10, 2009 at 1:07 PM, Pezza 
> wrote:
> >
> > > Hi
> >
> > > Just got everything rocking and rolling with the AutoMapper after some
> > > "ID" related problems. I would like to map all my "string" properties
> > > to varchar(x) columns and not nvarchar.
> >
> > > Have looked at ITypeConvention and .WithConvention but can't see the
> > > obvious place to override this setting.
> >
> > > Any help greatly appreciated.
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-10 Thread James Gregory
Well the Chunk isn't an override, it doesn't override anything. It allows
you to configure the model separately, whether you choose to override
something defined elsewhere is your decision. The chunk allows you to
configure the model in separate "chunks", not in one fell-swoop.
The IMappingOverride on the other hand is an override, hence why it's in the
name.

On Tue, Feb 10, 2009 at 2:26 PM, Billy  wrote:

>
> Heh, I have to admit that was the one thing that I didn't like
> either.  Technical aesthetics. ;)
>
> Why not a name which describes more what it's purpose is; e.g.,
> ConventionOverrideFor<>, AutoMapOverrideFor<> or something like that?
>
> Billy
>
>
> On Feb 10, 5:00 am, James Gregory  wrote:
> > ...and there's me thinking chunk was an amusing name ;)
> > ConfigPart, Configurer, Config, ConfigUnit, any ideas?
> >
> > On Tue, Feb 10, 2009 at 11:47 AM, Jimit  wrote:
> >
> > > That's it. :)
> >
> > > On Feb 10, 11:19 am, James Gregory  wrote:
> > > > What's wrong with the chunk? naming?
> >
> > > > On Tue, Feb 10, 2009 at 10:49 AM, Jimit 
> wrote:
> >
> > > > > +1 for the IMappingOverrides option. I ended up doing something
> pretty
> > > > > similar that works pretty well so far.:
> >
> > > > > public AutoPersistenceModel
> ApplyMappingOverridesFromAssembly(this
> > > > > AutoPersistenceModel)
> > > > > {
> >
> > > > >IEnumerable mappingOverrides =
> > > > > from type in
> > > > > typeof(T).Assembly.GetTypes()
> > > > > where
> > > > > type.IsSubClassOf(typeof (IMappingOverride<>))
> > > > > from method in
> > > > > type.GetMethods()
> > > > > where
> > > > > method.DeclaringType == type
> > > > >   &&
> > > > > method.ReturnType == typeof (void)
> > > > >   &&
> > > > > method.GetParameters().Count() == 1 &&
> >
> > > > > method.GetParameters()[0].ParameterType.
> >
> > > > > GetGenericTypeDefinition() ==
> > > > >   typeof
> > > > > (AutoMap<>)
> > > > > select method;
> > > > >mappingOverrides.ForEach(method =>
> > > > >   {
> > > > >   var entityType =
> > > > >
> method.GetParameters()
> > > > > [0].ParameterType.GetGenericArguments()[0];
> > > > >   var autoMapType = typeof
> > > > > (AutoMap<>).MakeGenericType(new[] {entityType});
> > > > >   var actionType = typeof
> > > > > (Action<>).MakeGenericType(new[] {autoMapType});
> > > > >   var mappingAction = new[]
> > > > > {Delegate.CreateDelegate(actionType, method)};
> >
> > > > > InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments(
> > > > >   model,
> > > > >   map =>
> > > > > map.ForTypesThatDeriveFrom(null),
> > > > >   mappingAction,
> > > > >   entityType);
> > > > >   });
> > > > >return model;
> > > > > }
> >
> > > > > Not too crazy about the IAutoMappingConfigChunk though.
> >
> > > > > On Feb 10, 12:15 am, Billy  wrote:
> > > > > > That strategy works for me.
> >
> > > > > > Thank you for being accommodating a viable approach to organizing
> > > > > > overrides.
> >
> > > > > > Billy
> >
> > > > > > On Feb 9, 4:37 pm, James Gregory 
> wrote:
> >
> > > > > > > Well, I'

[fluent-nhib] Re: Mapping to a view... can I?

2009-02-10 Thread James Gregory
Should be. Just use the view name instead of a table name. You won't be able
to do updates, but then you wouldn't want to with a search (I'd hope).

On Tue, Feb 10, 2009 at 3:39 PM, Steven Harman wrote:

> A question... I have a need to map to a denormalized view for the purpose
> of searching. I'm looking at Search as a separate bounded context, and as
> such am faking the boundary by making my search context go against
> denormalized views of my entities, optimized for search.
>
> So... is that doable via Fluent Nhibernate?
>
> -steve
>
> //  90% of being smart is knowing what you're dumb at  //
> http://stevenharman.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: FluentNhibernate and BurrowFramework

2009-02-10 Thread James Gregory
So are you receiving an instance of Configuration from Burrow? Ideally you'd
want to be able to pass that instance into the FNH config to be acted upon.

On Tue, Feb 10, 2009 at 3:51 PM, Mark Perry wrote:

>
> Hi
>
> Just trying to get FluentNHibernate and Burrow to work together for a
> web app I am working on.
>
> I can't seem to set the Nhibernate configuration that Burrow is using
> or get Burrow to pick up on the
> configuration set by Fluently.Configure. I know Nathan Stott managed
> to get it working but I have
> followed his advice and nothing is currently working for me.
>
> I can get the config from burrow by using:
>
> IFrameworkEnvironment fe = new BurrowFramework().BurrowEnvironment;
> NHibernate.Cfg.Configuration cfg = fe.GetNHConfig("PersistenceUnit1");
>
> //Do work on the config here.
> //I want to do cfg=Fluently.Configure() etc
> //But that doesn't work for me
>
> fe.RebuildSessionFactories();
>
> Can anyone help?
>
> Thanks, Mark
>
>
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-10 Thread James Gregory
It's official, I've implemented the generic configuration overrides (now
called IAutoMappingAlteration instead of Chunk), and the more specific
IMappingOverride.
You can read about both on the wiki,
overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>
and
configuration 
alterations<http://wiki.fluentnhibernate.org/show/AutoMappingConfigurationAlterations>
.

On Tue, Feb 10, 2009 at 2:33 PM, James Gregory wrote:

> Well the Chunk isn't an override, it doesn't override anything. It allows
> you to configure the model separately, whether you choose to override
> something defined elsewhere is your decision. The chunk allows you to
> configure the model in separate "chunks", not in one fell-swoop.
> The IMappingOverride on the other hand is an override, hence why it's in
> the name.
>
>
> On Tue, Feb 10, 2009 at 2:26 PM, Billy  wrote:
>
>>
>> Heh, I have to admit that was the one thing that I didn't like
>> either.  Technical aesthetics. ;)
>>
>> Why not a name which describes more what it's purpose is; e.g.,
>> ConventionOverrideFor<>, AutoMapOverrideFor<> or something like that?
>>
>> Billy
>>
>>
>> On Feb 10, 5:00 am, James Gregory  wrote:
>> > ...and there's me thinking chunk was an amusing name ;)
>> > ConfigPart, Configurer, Config, ConfigUnit, any ideas?
>> >
>> > On Tue, Feb 10, 2009 at 11:47 AM, Jimit  wrote:
>> >
>> > > That's it. :)
>> >
>> > > On Feb 10, 11:19 am, James Gregory  wrote:
>> > > > What's wrong with the chunk? naming?
>> >
>> > > > On Tue, Feb 10, 2009 at 10:49 AM, Jimit 
>> wrote:
>> >
>> > > > > +1 for the IMappingOverrides option. I ended up doing something
>> pretty
>> > > > > similar that works pretty well so far.:
>> >
>> > > > > public AutoPersistenceModel
>> ApplyMappingOverridesFromAssembly(this
>> > > > > AutoPersistenceModel)
>> > > > > {
>> >
>> > > > >IEnumerable mappingOverrides =
>> > > > > from type in
>> > > > > typeof(T).Assembly.GetTypes()
>> > > > > where
>> > > > > type.IsSubClassOf(typeof (IMappingOverride<>))
>> > > > > from method in
>> > > > > type.GetMethods()
>> > > > > where
>> > > > > method.DeclaringType == type
>> > > > >   &&
>> > > > > method.ReturnType == typeof (void)
>> > > > >   &&
>> > > > > method.GetParameters().Count() == 1 &&
>> >
>> > > > > method.GetParameters()[0].ParameterType.
>> >
>> > > > > GetGenericTypeDefinition() ==
>> > > > >   typeof
>> > > > > (AutoMap<>)
>> > > > > select method;
>> > > > >mappingOverrides.ForEach(method =>
>> > > > >   {
>> > > > >   var entityType =
>> > > > >
>> method.GetParameters()
>> > > > > [0].ParameterType.GetGenericArguments()[0];
>> > > > >   var autoMapType = typeof
>> > > > > (AutoMap<>).MakeGenericType(new[] {entityType});
>> > > > >   var actionType = typeof
>> > > > > (Action<>).MakeGenericType(new[] {autoMapType});
>> > > > >   var mappingAction =
>> new[]
>> > > > > {Delegate.CreateDelegate(actionType, method)};
>> >
>> > > > > InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments(
>> > > > >   model,
>> > > > >   map =>
>> > > > > map.ForTypesThatDeriveFrom(null),
>> > > > >   mapping

[fluent-nhib] Re: Perplexing Problem

2009-02-11 Thread James Gregory
You're not committing the transaction after your save. Have you tried that?

On Wed, Feb 11, 2009 at 11:03 AM, x97mdr  wrote:

>
> Hrm, I just tried that and no dice.  :(
>
> I was assigning the IDs because originally I wanted string-based
> identifiers (I'm applying this to a legacy database) so I had to
> assign the Id (or key name) to the objects.
>
> This is sooo frustrating, It seems like such a simple problem.  I'll
> turn on full log4net later today and see what happens with it.
>
> Any other suggestions in the meantime?
>
> On Feb 10, 9:35 pm, Paul Batum  wrote:
> > Hi there,
> >
> > I'm not sure what the problem is, but everything you are doing seems
> > perfectly normal EXCEPT assigning the ID's. Have you tried it without
> > assigning IDs explicitly?
> >
> > Paul Batum
> >
> > On Wed, Feb 11, 2009 at 1:24 PM, x97mdr 
> wrote:
> >
> > > I am just starting to learn NHibernate now, I tried setting up a very
> > > simple example to play around and for some reason I cannot get
> > > cascading to work.  I followed the example of the FirstExample project
> > > and tried to apply it to my domain.  I have two classes with a one-to-
> > > many relationship between them.  They are Variable and Relation
> > > (related to metadata we store in our environment).
> >
> > > The problem is that when I run the unit test which should save the
> > > relation and the related variable only the relation ever gets saved,
> > > if at all.
> >
> > > I have tried what seems to me to be every variation of the mappings to
> > > see if they would work but nothing has succeeded.  The weird thing is,
> > > the FirstExample project (for both SQLite and when I point it to SQL
> > > Server Express) seem to work fine.  There is something I am
> > > misunderstanding in my mappings.  I even tried switching between using
> > > Save and SaveOrUpdate on the session variable.  I'm using the trunk of
> > > the fluent-nhibernate project, including the nhibernate library in its
> > > tools directory (2.0.1)
> >
> > > Any help is greatly appreciated and sorry if its a bit of a newb
> > > question but its really bugging me!
> >
> > > Here are the classes for reference:
> >
> > >public class Variable : IEntity
> > >{
> > >public virtual long Id
> > >{
> > >get;
> > >set;
> > >}
> >
> > >public virtual Relation ParentRelation
> > >{
> > >get;
> > >set;
> > >}
> > >}
> >
> > >public class Relation : IEntity
> > >{
> > >public virtual long Id
> > >{
> > >get;
> > >set;
> > >}
> >
> > >public virtual IList Variables
> > >{
> > >get;
> > >set;
> > >}
> >
> > >public Relation()
> > >{
> > >Variables = new List();
> > >}
> >
> > >public virtual void AddQuestion(Variable item)
> > >{
> > >item.ParentRelation = this;
> > >Variables.Add(item);
> > >}
> > >}
> >
> > > and here are the mappings:
> >
> > >public class VariableMap : ClassMap
> > >{
> > >public VariableMap()
> > >{
> > >Id(x => x.Id);
> > >References(x => x.ParentRelation);
> > >}
> > >}
> >
> > >public class RelationMap : ClassMap
> > >{
> > >public RelationMap()
> > >{
> > >Id(x => x.Id);
> > >HasMany(x => x.Variables)
> > >.Inverse()
> > >.Cascade.All();
> > >}
> > >}
> >
> > > I have a little session provider to configure everything here:
> >
> > >public class MySessionProvider
> > >{
> > >private NHibernate.ISessionFactory _sessionFactory;
> > >private NHibernate.Cfg.Configuration _configuration;
> >
> > >public MySessionProvider()
> > >{
> > >_sessionFactory = Fluently.Configure()
> > >.Database(
> > >MsSqlConfiguration.MsSql2005
> > >.ConnectionString(x => x.Is
> > > (@"Server=BUMBLEBEE
> > > \SQLEXPRESS;Database=EditImputation;Trusted_Connection=True;"))
> > >.ShowSql()
> > >)
> > >.Mappings(x =>
> > > x.FluentMappings.AddFromAssemblyOf())
> > >.ExposeConfiguration
> > > (StoreConfiguration)
> > >.BuildSessionFactory();
> > >}
> >
> > >private void StoreConfiguration(NHibernate.Cfg.Configuration
> > > configuration)
> > >{
> > >_configuration = configuration;
> > >}
> >
> > >public NHibernate.ISession CreateSession()
> > >{
> > >return _sessionFactory.OpenSession();
> > >}
> >
> > >public void BuildSc

[fluent-nhib] Assemblies are signed

2009-02-11 Thread James Gregory
Guys,
Just to let you know, both assemblies are now signed. The fit framework that
was stopping us from signing has been removed as it wasn't in use. I've also
applied the AllowPartiallyTrustedCallers attribute, so this shouldn't bother
anyone that isn't signing themselves.

James

--~--~-~--~~~---~--~~
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: Perplexing Problem

2009-02-11 Thread James Gregory
Yes, you need to explicitly commit a transaction otherwise it gets rolled
back in the dispose. Although sometimes it can seem like things are being
saved, generally cascades don't occur until the transaction is committed.

On Wed, Feb 11, 2009 at 12:02 PM, x97mdr  wrote:

>
> I have tried it at times (though honestly, I have tried so many things
> now I'm not sure what I have tried together).  Originally I started
> out with a repository pattern object that automatically wrapped the
> save in a transaction and committed it.  I will give it another shot
> tonight though, I don't have the project here at work.
>
> When the IDbTransaction is in a using statement do you still have to
> commit it?
>
> On Feb 11, 6:11 am, James Gregory  wrote:
> > You're not committing the transaction after your save. Have you tried
> that?
> >
> > On Wed, Feb 11, 2009 at 11:03 AM, x97mdr 
> wrote:
> >
> > > Hrm, I just tried that and no dice.  :(
> >
> > > I was assigning the IDs because originally I wanted string-based
> > > identifiers (I'm applying this to a legacy database) so I had to
> > > assign the Id (or key name) to the objects.
> >
> > > This is sooo frustrating, It seems like such a simple problem.  I'll
> > > turn on full log4net later today and see what happens with it.
> >
> > > Any other suggestions in the meantime?
> >
> > > On Feb 10, 9:35 pm, Paul Batum  wrote:
> > > > Hi there,
> >
> > > > I'm not sure what the problem is, but everything you are doing seems
> > > > perfectly normal EXCEPT assigning the ID's. Have you tried it without
> > > > assigning IDs explicitly?
> >
> > > > Paul Batum
> >
> > > > On Wed, Feb 11, 2009 at 1:24 PM, x97mdr 
> > > wrote:
> >
> > > > > I am just starting to learn NHibernate now, I tried setting up a
> very
> > > > > simple example to play around and for some reason I cannot get
> > > > > cascading to work.  I followed the example of the FirstExample
> project
> > > > > and tried to apply it to my domain.  I have two classes with a
> one-to-
> > > > > many relationship between them.  They are Variable and Relation
> > > > > (related to metadata we store in our environment).
> >
> > > > > The problem is that when I run the unit test which should save the
> > > > > relation and the related variable only the relation ever gets
> saved,
> > > > > if at all.
> >
> > > > > I have tried what seems to me to be every variation of the mappings
> to
> > > > > see if they would work but nothing has succeeded.  The weird thing
> is,
> > > > > the FirstExample project (for both SQLite and when I point it to
> SQL
> > > > > Server Express) seem to work fine.  There is something I am
> > > > > misunderstanding in my mappings.  I even tried switching between
> using
> > > > > Save and SaveOrUpdate on the session variable.  I'm using the trunk
> of
> > > > > the fluent-nhibernate project, including the nhibernate library in
> its
> > > > > tools directory (2.0.1)
> >
> > > > > Any help is greatly appreciated and sorry if its a bit of a newb
> > > > > question but its really bugging me!
> >
> > > > > Here are the classes for reference:
> >
> > > > >public class Variable : IEntity
> > > > >{
> > > > >public virtual long Id
> > > > >{
> > > > >get;
> > > > >set;
> > > > >}
> >
> > > > >public virtual Relation ParentRelation
> > > > >{
> > > > >get;
> > > > >set;
> > > > >}
> > > > >}
> >
> > > > >public class Relation : IEntity
> > > > >{
> > > > >public virtual long Id
> > > > >{
> > > > >get;
> > > > >set;
> > > > >}
> >
> > > > >public virtual IList Variables
> > > > >{
> > > > >get;
> > > > >set;
> > > > >}
> >
> > > > >public Relation()
> > > > >{
> > > > &g

[fluent-nhib] Re: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-11 Thread James Gregory
Can you show us the code that's actually saving the entities?
These two wiki pages show the ways you can customise automappings: altering
entities 
and
mapping overrides
.

On Wed, Feb 11, 2009 at 8:43 PM, Ramana Kumar wrote:

> No, I did mean Many to One :-)  The Domain Objects are Golfer and Address
> and many Golfers can share the same Address.  Per James
> "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
> one. I am just not sure how to do it thru AutoMap conventions.
> HTH
> Ramana
>
>
>  namespace GolfHandicapManager.Core
> {
> public class Golfer : Entity
> {
> public Golfer() { }
> [DomainSignature]
> [NotNullNotEmpty]
> public virtual string FirstName { get; set; }
> [DomainSignature]
> [NotNullNotEmpty]
> public virtual string LastName { get; set; }
> [NotNullNotEmpty]
> public virtual string EmailAddress { get; set; }
>   public virtual string EmailAddress2 { get; set; }
>   public virtual string HomePhone { get; set; }
>   public virtual string CellPhone { get; set; }
> public virtual Address Address { get; set; }
> }
> public class Address : Entity
> {
> public Address() { }
> [DomainSignature]
>   public virtual string Addr1 { get; set; }
>   public virtual string Addr2 { get; set; }
> [DomainSignature]
>   public virtual string City { get; set; }
>   public virtual string State { get; set; }
>   public virtual string Country { get; set; }
>   public virtual string ZipCode { get; set; }
> }
> }
>
>
>
> On Wed, Feb 11, 2009 at 2:05 PM, Chris Marisic  wrote:
>
>>
>> Do you mean One to Many?
>>
>> convention.OneToManyConvention = m =>
>> {
>>m.Cascade.All();
>> };
>>
>> On Feb 11, 1:58 pm, Ramana Kumar  wrote:
>> > Hi
>> > I am trying to use AutoMap to define behaviour for ManyToOne and I get
>> the
>> > following exception
>> >
>> > object references an unsaved transient instance - save the transient
>> > instance before flushing:
>> >
>> > The relevant code is
>> >
>> >  public class AutoPersistenceModelGenerator :
>> IAutoPersistenceModelGenerator
>> > {
>> > public AutoPersistenceModel Generate()
>> > {
>> > AutoPersistenceModel mappings = AutoPersistenceModel
>> > .MapEntitiesFromAssemblyOf()
>> > .Where(GetAutoMappingFilter)
>> > .WithConvention(GetConventions);
>> > return mappings;
>> > }
>> >
>> > private bool GetAutoMappingFilter(Type t)
>> > {
>> > return t.Namespace == "GolfHandicapManager.Core";
>> > }
>> > private void GetConventions(Conventions c)
>> > {
>> > c.GetPrimaryKeyNameFromType = type => "ROW_ID";  //DB has
>> ROW_ID
>> > as Primary Key
>> > c.FindIdentity = type => type.Name == "ID"; // S#arp
>> currently
>> > uses "ID"
>> > // Taken from Ayende Blog
>> > c.GetForeignKeyNameOfParent = (type => type.Name + "_ID");
>> > c.GetTableName = type =>
>> > Inflector.Net.Inflector.Pluralize(type.Name);
>> > c.IsBaseType = IsBaseTypeConvention;
>> > // Convert PropertyName to Underscore
>> > c.AddPropertyConvention(new
>> > PascalToUnderscorePropertyConvention());
>> > }
>> >
>> > I am assuming I have to do a "cascade=all" somewhere in there but do not
>> > know how to do it thru a convention.
>> >
>> > Any pointers?
>> > Thanks
>> > Ramana
>> >>
>>

--~--~-~--~~~---~--~~
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: AutoMapper How to set dynamic-update on Class

2009-02-11 Thread James Gregory
There currently isn't support for class wide conventions, and we don't have
support for dynamic-update either, so this is a bit of a problem!
I'll look at addressing these two issues asap.

On Wed, Feb 11, 2009 at 5:32 PM, Mark Perry wrote:

>
> Hi
>
> Is there a way I can get conventions on my class mappings using the
> auto mapper. I would like to turn on Dynamic-Update on all my mappings
> but I cannot find any examples online
> or in the conventions API?
>
> Thanks, Mark
> >
>

--~--~-~--~~~---~--~~
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: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-11 Thread James Gregory
Chris, it definitely shouldn't be a one-to-one. I'd say his mapping is
correct. If two golfers shared an address, and one of them changed then
you'd insert a new record for the new address and update the related golfer,
it's still a many-to-one.
Please refer to my blog post about this:
http://blog.jagregory.com/2009/01/27/i-think-you-mean-a-many-to-one-sir/

If you find yourself suggesting or mapping a one-to-one, then you're
probably doing it wrong. True one-to-one's are very rare.

On Wed, Feb 11, 2009 at 9:00 PM, Chris Marisic  wrote:

>
> I think I'd have to disagree with that being a many to one situation.
> That in my opinion SHOULD be a one to many. A golfer can have many
> addresses, if you only care about a single address, it should be a 1
> to 1 association.
>
> Having multiple golfers share 1 address is wrong even if they have the
> same physical street address. How do you differentiate if the address
> changes, say becomes a mailbox number. At that point you change the
> address of one of the golfers you just updated every golfer that had
> that address. I understand the point of databases is to minimize data
> duplication but IMO this is a wrong application of it.
>
> Seeing what you're attempting I'm going to assume most likely in your
> edit address place you are creating a new address for that person then
> trying to save the person. This would most likely leave the original
> address object in the session as transient which gives you this error.
> My guess would be something along the lines:
>
> var prevAddress = golfer.Address;
>
> golfer.Address = new Address(...)
>
> session.Save(prevAddress)
>
> session.Save(person)
>
> session.Flush()
>
> On Feb 11, 3:43 pm, Ramana Kumar  wrote:
> > No, I did mean Many to One :-)  The Domain Objects are Golfer and Address
> > and many Golfers can share the same Address.  Per James
> > "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
> > one. I am just not sure how to do it thru AutoMap conventions.
> > HTH
> > Ramana
> >
> >  namespace GolfHandicapManager.Core
> > {
> > public class Golfer : Entity
> > {
> > public Golfer() { }
> > [DomainSignature]
> > [NotNullNotEmpty]
> > public virtual string FirstName { get; set; }
> > [DomainSignature]
> > [NotNullNotEmpty]
> > public virtual string LastName { get; set; }
> > [NotNullNotEmpty]
> > public virtual string EmailAddress { get; set; }
> >   public virtual string EmailAddress2 { get; set; }
> >   public virtual string HomePhone { get; set; }
> >   public virtual string CellPhone { get; set; }
> > public virtual Address Address { get; set; }
> > }
> > public class Address : Entity
> > {
> > public Address() { }
> > [DomainSignature]
> >   public virtual string Addr1 { get; set; }
> >   public virtual string Addr2 { get; set; }
> > [DomainSignature]
> >   public virtual string City { get; set; }
> >   public virtual string State { get; set; }
> >   public virtual string Country { get; set; }
> >   public virtual string ZipCode { get; set; }
> > }
> >
> > }
> > On Wed, Feb 11, 2009 at 2:05 PM, Chris Marisic 
> wrote:
> >
> > > Do you mean One to Many?
> >
> > > convention.OneToManyConvention = m =>
> > > {
> > >m.Cascade.All();
> > > };
> >
> > > On Feb 11, 1:58 pm, Ramana Kumar  wrote:
> > > > Hi
> > > > I am trying to use AutoMap to define behaviour for ManyToOne and I
> get
> > > the
> > > > following exception
> >
> > > > object references an unsaved transient instance - save the transient
> > > > instance before flushing:
> >
> > > > The relevant code is
> >
> > > >  public class AutoPersistenceModelGenerator :
> > > IAutoPersistenceModelGenerator
> > > > {
> > > > public AutoPersistenceModel Generate()
> > > > {
> > > > AutoPersistenceModel mappings = AutoPersistenceModel
> > > > .MapEntitiesFromAssemblyOf()
> > > > .Where(GetAutoMappingFilter)
> > > > .WithConvention(GetConventions);
> > > > return mappings;
> > > > }
> >
> > > > private bool GetAutoMappingFilter(Type t)
> > > > {
> > > > return t.Namespace == "GolfHandicapManager.Core";
> > > > }
> > > > private void GetConventions(Conventions c)
> > > > {
> > > > c.GetPrimaryKeyNameFromType = type => "ROW_ID";  //DB has
> > > ROW_ID
> > > > as Primary Key
> > > > c.FindIdentity = type => type.Name == "ID"; // S#arp
> > > currently
> > > > uses "ID"
> > > > // Taken from Ayende Blog
> > > > c.GetForeignKeyNameOfParent = (type => type.Name +
> "_ID");
> > > > c.GetTableName = type =>
> > > > Inflector.Net.Inflector.Pluralize(type.Name);
> > > > c.IsBaseType = IsBaseTypeConvention;
> > > > // Convert PropertyName to Underscore
> > > > c.AddPropertyConve

[fluent-nhib] Re: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-11 Thread James Gregory
Any relationship in a non ORM world can be a nightmare, that's why we're
using NHibernate. Orphans are handled nicely by NHs Cascade.AllDeleteOrphan.

As for one-to-one vs many-to-one, you're not making the distinction between
domain and database. The database doesn't care about shared resources, if
one table can have multiple records referencing a single row in another,
it's a many-to-one; regardless of whether your domain has that being correct
or not.  When we're talking about these patterns, we're discussing how the
database is mapped - it's irrelevant of your business rules, or
preconceptions of what can and can not be shared.
A one-to-one is almost never the answer. Unless your tables have
identical primary
key values, it isn't a one-to-one relationship.

These rules are entirely the concern of the domain, and whether you treat it
as a one-to-one in that is completely unrelated to the underlying table
structure pattern.

On Wed, Feb 11, 2009 at 9:28 PM, Chris Marisic  wrote:

>
> You don't really deal with the fact if you follow the many to 1
> pattern you now have to also deal with orphaned objects. I've
> previously developed a system entirely by hand implementing the many
> to one pattern. I will never forget the fact that every single insert/
> update of a given type (address, phone) required about 5 procedure/
> function calls to manipulate keeping the ids correct and making sure
> records don't become orphaned.
>
> I'm sure NHibernate offers a way to make it not a catastrophe for the
> developer to deal with but I still disagree with it in practice since
> I don't believe in most cases where it's used that it's correct. 3
> people sharing an address should be 3 entries in the database in my
> opinion. If anyone of them changes or deletes their address it
> shouldn't have to figure out if changing their address will impact
> others.
>
> IMO the only time the many to 1 pattern is valid is on something you
> own that you share. Say a resource like a golf cart. Many people can
> share that golf cart, updating that golf cart should change every
> persons view of that golf cart.
>
> On Feb 11, 4:09 pm, James Gregory  wrote:
> > Chris, it definitely shouldn't be a one-to-one. I'd say his mapping is
> > correct. If two golfers shared an address, and one of them changed then
> > you'd insert a new record for the new address and update the related
> golfer,
> > it's still a many-to-one.
> > Please refer to my blog post about this:
> http://blog.jagregory.com/2009/01/27/i-think-you-mean-a-many-to-one-sir/
> >
> > If you find yourself suggesting or mapping a one-to-one, then you're
> > probably doing it wrong. True one-to-one's are very rare.
> >
> > On Wed, Feb 11, 2009 at 9:00 PM, Chris Marisic 
> wrote:
> >
> > > I think I'd have to disagree with that being a many to one situation.
> > > That in my opinion SHOULD be a one to many. A golfer can have many
> > > addresses, if you only care about a single address, it should be a 1
> > > to 1 association.
> >
> > > Having multiple golfers share 1 address is wrong even if they have the
> > > same physical street address. How do you differentiate if the address
> > > changes, say becomes a mailbox number. At that point you change the
> > > address of one of the golfers you just updated every golfer that had
> > > that address. I understand the point of databases is to minimize data
> > > duplication but IMO this is a wrong application of it.
> >
> > > Seeing what you're attempting I'm going to assume most likely in your
> > > edit address place you are creating a new address for that person then
> > > trying to save the person. This would most likely leave the original
> > > address object in the session as transient which gives you this error.
> > > My guess would be something along the lines:
> >
> > > var prevAddress = golfer.Address;
> >
> > > golfer.Address = new Address(...)
> >
> > > session.Save(prevAddress)
> >
> > > session.Save(person)
> >
> > > session.Flush()
> >
> > > On Feb 11, 3:43 pm, Ramana Kumar  wrote:
> > > > No, I did mean Many to One :-)  The Domain Objects are Golfer and
> Address
> > > > and many Golfers can share the same Address.  Per James
> > > > "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many
> to
> > > > one. I am just not sure how to do it thru AutoMap conventions.
> > > > HTH
> > > > Ramana
> >
> > 

[fluent-nhib] Re: AutoMapper How to set dynamic-update on Class

2009-02-11 Thread James Gregory
There are now conventions for DynamicUpdate, DynamicInsert, and
OptimisticLock.
WithConventions(convention =>
{
  convention.DynamicUpdate = type => true;
  convention.DynamicInsert = type => true;
  convention.OptimisticLock = (type, locking) => locking.Version();
});

I'm going to look at the bigger issue of why there's no way to specify your
own class conventions ala ITypeConvention soon.

On Wed, Feb 11, 2009 at 9:04 PM, James Gregory wrote:

> There currently isn't support for class wide conventions, and we don't have
> support for dynamic-update either, so this is a bit of a problem!
> I'll look at addressing these two issues asap.
>
>
> On Wed, Feb 11, 2009 at 5:32 PM, Mark Perry wrote:
>
>>
>> Hi
>>
>> Is there a way I can get conventions on my class mappings using the
>> auto mapper. I would like to turn on Dynamic-Update on all my mappings
>> but I cannot find any examples online
>> or in the conventions API?
>>
>> Thanks, Mark
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Obscure Mapping Error

2009-02-12 Thread James Gregory
etGenericTypeDefinition
> > ().IsIn(new[]
> >
> > {
> >
> > typeof (EntityBase<,>),
> >
> > typeof (EntityBase<>),
> >
> > typeof (ProcessedEntity<,>),
> >
> > typeof (ProcessedEntity<>),
> >
> > typeof (AuditedEntity<,>),
> >
> > typeof (AuditedEntity<>),
> >
> > typeof (ProcessingEvent<>)
> >
> }));
> > //conventions.IsComponentType = t => t == typeof(Address);
> > conventions.OneToManyConvention = map =>
> > map.Cascade.SaveUpdate();
> > conventions.DefaultLazyLoad = true;
> > conventions.GetForeignKeyNameOfParent = parent =>
> > parent.Name + "ID";
> > conventions.IdConvention = identity => identity
> >.Access.
> >
> > AsReadOnlyPropertyThroughPascalCaseField
> >
> > (Prefix.Underscore)
> >
>  .GeneratedBy.Native
> > ()
> >.TheColumnNameIs
> > ("Id");
> > conventions.GetForeignKeyName = property => property.Name
> > + "Id";
> > conventions.GetManyToManyTableName =
> > (parent, child) => parent.Name + "_" + child.Name;
> > conventions.DefaultCache = cache => cache.AsReadWrite();
> > conventions.GetParentSideForManyToMany = (type1, type2) =>
> >  {
> >  var types
> > = (new[] {type1, type2})
> >  .OrderBy
> > (t => t.Name);
> >  return
> > types.Where(
> >
> > t => typeof (IAggregateRoot)
> >
>.IsAssignableFrom
> > (t))
> >
> .FirstOrDefault
> > () ??
> >
> > types.First();
> >  };
> > }
> >
> > private static void AddCustomConventions
> > (FluentNHibernate.Conventions conventions)
> > {
> > // Add type conventions
> > conventions.AddTypeConvention(new DescriptionTypeConvention
> > ());
> > conventions.AddTypeConvention(new NameTypeConvention());
> > conventions.AddTypeConvention(new ReferenceTypeConvention
> > ());
> >
> > // Add property conventions
> > conventions.AddPropertyConvention(new
> > ForeignKeyMapsToEnum(o => o.Status));
> > conventions.AddPropertyConvention(new AuditingConvention
> > ());
> > }
> >
> > public static AutoPersistenceModel
> > WithCustomMappingsFrom(this AutoPersistenceModel model)
> > {
> > (from method in typeof (TCustomMapper).GetMethods()
> >  where method.DeclaringType == typeof (TCustomMapper)
> >&& method.ReturnType == typeof (void)
> >&& method.GetParameters().Count() == 1 &&
> >method.GetParameters()[0].ParameterType.
> >GetGenericTypeDefinition() ==
> >typeof (AutoMap<>)
> >  select method).ForEach(method =>
> > {
> > var autoMapType =
> > method.GetParameters()[0].ParameterType;
> > var entityType =
> > autoMapType.GetGenericArguments()[0];
> > var actionType = typeof
> > (Action<>).MakeGenericType(new[] {autoMapType});
> > var mappingAction = new[]
> > {Delegate.CreateDelegate(actionType, method)};
> >
> > InvocationHelper.InvokeGenericMethodWithDynamicTypeArguments(
> > model,
> > map =>
> > map.ForTypesThatDeriveFrom(null),
> > mappingAction,
> > entityType);
> > });
> > return model;
> > }
> >
> > }
> >
> > The relevent action in CustomMappings is:
> >
> > public class CustomMappi

[fluent-nhib] Re: Perplexing Problem

2009-02-12 Thread James Gregory
Your table is ending up with three columns because the HasMany in Relation
is called Variables but the other side of the relation is called
ParentRelation; this is causing FNH to not see them as two sides of the same
relationship. Try calling TheColumnNameIs on your ParentRelation and giving
it "Relation_id".
Making that change might actually fix your saving issue.

On Thu, Feb 12, 2009 at 12:35 AM, x97mdr  wrote:

>
> OK I changed my test fixture to this:
>
>[TestMethod]
>public void Can_Add_Variable()
>{
>var relation = new Relation();
> var variable = new Variable();
>relation.AddVariable(variable);
>
>using (var session = sessionProvider.CreateSession())
>{
>using (var transaction = session.BeginTransaction())
>{
>session.Save(relation);
> transaction.Commit();
>}
>}
>}
>
> And the relation is saving, but the variable is not. So no cascading
> is happening.  Then I modified the VariableMap class to this:
>
>public class VariableMap : ClassMap
>{
>public VariableMap()
>{
>Id(x => x.Id);
>References(x => x.ParentRelation)
> .Cascade.All();
>}
>}
>
> And it works, though my Variable table has three columns Id,
> ParentRelation_id and Relation_id where Relation_id remains NULL.
>
> Any thoughts?  It's weird that I had to ask the Cascade.All() to the
> References column of the variable when it doesn't appear to be needed
> based on the FirstExample project.  Also, weird that there are three
> columns on the Variable table when I would expect at most 2 columns
> since ParentRelation is set to be the References in the mapping.
>
> Would it be helpful for me to post my entire solution I wonder?
>
> Thansk so much for your suggestions thus far.
>
> On Feb 11, 7:08 am, James Gregory  wrote:
> > Yes, you need to explicitly commit a transaction otherwise it gets rolled
> > back in the dispose. Although sometimes it can seem like things are being
> > saved, generally cascades don't occur until the transaction is committed.
> >
> > On Wed, Feb 11, 2009 at 12:02 PM, x97mdr 
> wrote:
> >
> > > I have tried it at times (though honestly, I have tried so many things
> > > now I'm not sure what I have tried together).  Originally I started
> > > out with a repository pattern object that automatically wrapped the
> > > save in a transaction and committed it.  I will give it another shot
> > > tonight though, I don't have the project here at work.
> >
> > > When the IDbTransaction is in a using statement do you still have to
> > > commit it?
> >
> > > On Feb 11, 6:11 am, James Gregory  wrote:
> > > > You're not committing the transaction after your save. Have you tried
> > > that?
> >
> > > > On Wed, Feb 11, 2009 at 11:03 AM, x97mdr 
> > > wrote:
> >
> > > > > Hrm, I just tried that and no dice.  :(
> >
> > > > > I was assigning the IDs because originally I wanted string-based
> > > > > identifiers (I'm applying this to a legacy database) so I had to
> > > > > assign the Id (or key name) to the objects.
> >
> > > > > This is sooo frustrating, It seems like such a simple problem.
>  I'll
> > > > > turn on full log4net later today and see what happens with it.
> >
> > > > > Any other suggestions in the meantime?
> >
> > > > > On Feb 10, 9:35 pm, Paul Batum  wrote:
> > > > > > Hi there,
> >
> > > > > > I'm not sure what the problem is, but everything you are doing
> seems
> > > > > > perfectly normal EXCEPT assigning the ID's. Have you tried it
> without
> > > > > > assigning IDs explicitly?
> >
> > > > > > Paul Batum
> >
> > > > > > On Wed, Feb 11, 2009 at 1:24 PM, x97mdr <
> jeffreycame...@gmail.com>
> > > > > wrote:
> >
> > > > > > > I am just starting to learn NHibernate now, I tried setting up
> a
> > > very
> > > > > > > simple example to play around and for some reason I cannot get
> > > > > > > cascading to work.  I followed the example of the FirstExample
> > > project
> > > > > > > and tried to apply it to my domain.  I have two classes with a
> > > one-to-
>

[fluent-nhib] Re: Perplexing Problem

2009-02-12 Thread James Gregory
Sorry, that should have been WithKeyColumn rather than TheColumnNameIs.

On Thu, Feb 12, 2009 at 8:58 AM, James Gregory wrote:

> Your table is ending up with three columns because the HasMany in Relation
> is called Variables but the other side of the relation is called
> ParentRelation; this is causing FNH to not see them as two sides of the same
> relationship. Try calling TheColumnNameIs on your ParentRelation and giving
> it "Relation_id".
> Making that change might actually fix your saving issue.
>
>
> On Thu, Feb 12, 2009 at 12:35 AM, x97mdr  wrote:
>
>>
>> OK I changed my test fixture to this:
>>
>>[TestMethod]
>>public void Can_Add_Variable()
>>{
>>var relation = new Relation();
>> var variable = new Variable();
>>relation.AddVariable(variable);
>>
>>using (var session = sessionProvider.CreateSession())
>>{
>>using (var transaction = session.BeginTransaction())
>>{
>>session.Save(relation);
>> transaction.Commit();
>>}
>>}
>>}
>>
>> And the relation is saving, but the variable is not. So no cascading
>> is happening.  Then I modified the VariableMap class to this:
>>
>>public class VariableMap : ClassMap
>>{
>>public VariableMap()
>>{
>>Id(x => x.Id);
>>References(x => x.ParentRelation)
>> .Cascade.All();
>>}
>>}
>>
>> And it works, though my Variable table has three columns Id,
>> ParentRelation_id and Relation_id where Relation_id remains NULL.
>>
>> Any thoughts?  It's weird that I had to ask the Cascade.All() to the
>> References column of the variable when it doesn't appear to be needed
>> based on the FirstExample project.  Also, weird that there are three
>> columns on the Variable table when I would expect at most 2 columns
>> since ParentRelation is set to be the References in the mapping.
>>
>> Would it be helpful for me to post my entire solution I wonder?
>>
>> Thansk so much for your suggestions thus far.
>>
>> On Feb 11, 7:08 am, James Gregory  wrote:
>> > Yes, you need to explicitly commit a transaction otherwise it gets
>> rolled
>> > back in the dispose. Although sometimes it can seem like things are
>> being
>> > saved, generally cascades don't occur until the transaction is
>> committed.
>> >
>> > On Wed, Feb 11, 2009 at 12:02 PM, x97mdr 
>> wrote:
>> >
>> > > I have tried it at times (though honestly, I have tried so many things
>> > > now I'm not sure what I have tried together).  Originally I started
>> > > out with a repository pattern object that automatically wrapped the
>> > > save in a transaction and committed it.  I will give it another shot
>> > > tonight though, I don't have the project here at work.
>> >
>> > > When the IDbTransaction is in a using statement do you still have to
>> > > commit it?
>> >
>> > > On Feb 11, 6:11 am, James Gregory  wrote:
>> > > > You're not committing the transaction after your save. Have you
>> tried
>> > > that?
>> >
>> > > > On Wed, Feb 11, 2009 at 11:03 AM, x97mdr 
>> > > wrote:
>> >
>> > > > > Hrm, I just tried that and no dice.  :(
>> >
>> > > > > I was assigning the IDs because originally I wanted string-based
>> > > > > identifiers (I'm applying this to a legacy database) so I had to
>> > > > > assign the Id (or key name) to the objects.
>> >
>> > > > > This is sooo frustrating, It seems like such a simple problem.
>>  I'll
>> > > > > turn on full log4net later today and see what happens with it.
>> >
>> > > > > Any other suggestions in the meantime?
>> >
>> > > > > On Feb 10, 9:35 pm, Paul Batum  wrote:
>> > > > > > Hi there,
>> >
>> > > > > > I'm not sure what the problem is, but everything you are doing
>> seems
>> > > > > > perfectly normal EXCEPT assigning the ID's. Have you tried it
>> without
>> > > > > > assigning IDs explicitly?
>> >
>> > > > > > Paul Batum
>> >
>> > > > >

[fluent-nhib] Re: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-12 Thread James Gregory
Those wiki pages cover how you'd set the cascade.
ForTypesThatDeriveFrom(m =>
{
  m.References(x => Address)
.Cascade.All();
})

On Thu, Feb 12, 2009 at 12:09 AM, Ramana Kumar wrote:

> I will go back home and check the wiki pages.  In the meantime, here is
> what I use to save
>
> [Transaction]
> [AcceptVerbs(HttpVerbs.Post)]
> public ActionResult Create(Golfer golfer) {
> if (golfer.IsValid()) {
> golferRepository.SaveOrUpdate(golfer);
> TempData["message"] = "The golfer was successfully
> created.";
> return RedirectToAction("Index");
> }
> else {
>
> MvcValidationAdapter.TransferValidationMessagesTo(ViewData.ModelState,
> golfer.ValidationResults());
> return View();
> }
> }
>
> When I put it the thru the debugger, I see that golfer instance has correct
> values (from the form) for FirstName, LastName, Email as well as
> Address.Addr1, Address.City etc populated correctly.
>
>  BTW, SaveOrUpdate if fine and when the "Create" method ends (i.e. the
> transaction is complete) then I get the exception.  Obviously, because the
> flush is thrwoing the exception.
>
> I still suspect that "cascade" on ManyToOne needs to set to "all", I am not
> sure how to do it.
> Thanks
> Ramana
>
>
> On Wed, Feb 11, 2009 at 2:59 PM, James Gregory wrote:
>
>> Can you show us the code that's actually saving the entities?
>> These two wiki pages show the ways you can customise automappings: altering
>> entities<http://wiki.fluentnhibernate.org/show/AutoMappingAlteringEntities> 
>> and
>> mapping 
>> overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>.
>>
>>
>>
>> On Wed, Feb 11, 2009 at 8:43 PM, Ramana Kumar 
>> wrote:
>>
>>> No, I did mean Many to One :-)  The Domain Objects are Golfer and Address
>>> and many Golfers can share the same Address.  Per James
>>> "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
>>> one. I am just not sure how to do it thru AutoMap conventions.
>>> HTH
>>> Ramana
>>>
>>>
>>>  namespace GolfHandicapManager.Core
>>> {
>>> public class Golfer : Entity
>>> {
>>> public Golfer() { }
>>> [DomainSignature]
>>> [NotNullNotEmpty]
>>> public virtual string FirstName { get; set; }
>>> [DomainSignature]
>>> [NotNullNotEmpty]
>>> public virtual string LastName { get; set; }
>>> [NotNullNotEmpty]
>>> public virtual string EmailAddress { get; set; }
>>>   public virtual string EmailAddress2 { get; set; }
>>>   public virtual string HomePhone { get; set; }
>>>   public virtual string CellPhone { get; set; }
>>> public virtual Address Address { get; set; }
>>> }
>>> public class Address : Entity
>>> {
>>> public Address() { }
>>> [DomainSignature]
>>>   public virtual string Addr1 { get; set; }
>>>   public virtual string Addr2 { get; set; }
>>> [DomainSignature]
>>>   public virtual string City { get; set; }
>>>   public virtual string State { get; set; }
>>>   public virtual string Country { get; set; }
>>>   public virtual string ZipCode { get; set; }
>>> }
>>> }
>>>
>>>
>>>
>>> On Wed, Feb 11, 2009 at 2:05 PM, Chris Marisic wrote:
>>>
>>>>
>>>> Do you mean One to Many?
>>>>
>>>> convention.OneToManyConvention = m =>
>>>> {
>>>>m.Cascade.All();
>>>> };
>>>>
>>>> On Feb 11, 1:58 pm, Ramana Kumar  wrote:
>>>> > Hi
>>>> > I am trying to use AutoMap to define behaviour for ManyToOne and I get
>>>> the
>>>> > following exception
>>>> >
>>>> > object references an unsaved transient instance - save the transient
>>>> > instance before flushing:
>>>> >
>>>> > The relevant code is
>>>> >
>>>> >  public class AutoPersistenceModelGenerator :
>>>> IAutoPersistenceModelGenerator
>>>> > {
>>>> > public AutoPersistenceModel Generate()
>>>> > {
>>>> > AutoPersistenceModel mapp

[fluent-nhib] Re: Overriding auto-mappings to use a composite key

2009-02-12 Thread James Gregory
Hey Jon,
Do you actually have a property called ActivityTypeId on Activity? That's a
little odd, surely it should just be an ActivityType property. Maybe I'm
misreading your code.

You've definitely struck an unconsidered situation here, but I don't think
it'd be too difficult to fix (I'll end up just doing the same as what you've
done, just hidden inside the automapper).

On Wed, Feb 11, 2009 at 5:32 PM, Jon Kruger  wrote:

>
> OK, I solved my own problem apparently, but it's not that pretty.  I
> added an override class that looks like this:
>
>public class ActivityMappingOverride :
> IAutoMappingOverride
>{
>public void Override(AutoMap mapping)
>{
>mapping.UseCompositeId()
>.WithKeyProperty(x => x.Id)
>.WithKeyProperty(x => x.ActivityTypeId,
> "ActivityType_id");
>mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> ("Id"));
>mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> ("ActivityTypeId"));
>}
>}
>
> A couple things that look fishy:
>
> 1) I had to hardcode the column name of ActivityType_id, I wish I
> could've said .WithKeyProperty(x => x.ActivityType) and have it figure
> out that I want to use the id from ActivityType
> 2) I had to tell the mapping class that I already mapped the two
> properties or it would make an Id() mapping for Id and a Map() mapping
> for ActivityType_id when the automapper ran.  The many-to-one is still
> created though (which is good).
> >
>

--~--~-~--~~~---~--~~
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: Perplexing Problem

2009-02-12 Thread James Gregory
The FirstProject example was originally written against SQLExpress, but I'll
have a test tonight.

On Thu, Feb 12, 2009 at 2:32 PM, x97mdr  wrote:

>
> I renamed the Relation field back to ParentRelation and modified the
> VariableMap back to this:
>
>public class VariableMap : ClassMap
>{
>public VariableMap()
>{
>Id(x => x.Id);
>References(x => x.ParentRelation)
> .WithForeignKey("Relation_id")
>.TheColumnNameIs("Relation_id")
>.Cascade.All();
>}
>}
>
> The appropriate columns are now created, but the cascading no longer
> works. :(  Relation seems to have been created, but the Variable
> information was not.  Is there a bug in here somewhere?
>
> Actually, I just tried running the FirstExample project from the trunk
> again (which I was using as an example for my own project here).  When
> I replaced the configuration to point to SQL Server (see below for
> modified CreateSessionFactory method) the References relationship does
> not work there either ... I really think there is a bug here with the
> References or HasMany methods, either that or its my configuration,
> but my config is pretty basic.  Try the FirstExample project but
> examine the database after it has run (save it to SQL Server or
> something) and see if the information is actually persisted in the
> tables or not.
>
>private static ISessionFactory CreateSessionFactory()
>{
>return Fluently.Configure()
> .Database(MsSqlConfiguration
>.MsSql2005
>.ConnectionString(x => x.Is
> (@"Server=BUMBLEBEE
> \SQLEXPRESS;Database=EditImputation;Trusted_Connection=True;"))
>.ShowSql())
> .Mappings(m =>
>    m.FluentMappings.AddFromAssemblyOf())
>.ExposeConfiguration(BuildSchema)
>.BuildSessionFactory();
>     }
>
>
> On Feb 12, 3:59 am, James Gregory  wrote:
> > Sorry, that should have been WithKeyColumn rather than TheColumnNameIs.
> >
> > On Thu, Feb 12, 2009 at 8:58 AM, James Gregory  >wrote:
> >
> > > Your table is ending up with three columns because the HasMany in
> Relation
> > > is called Variables but the other side of the relation is called
> > > ParentRelation; this is causing FNH to not see them as two sides of the
> same
> > > relationship. Try calling TheColumnNameIs on your ParentRelation and
> giving
> > > it "Relation_id".
> > > Making that change might actually fix your saving issue.
> >
> > > On Thu, Feb 12, 2009 at 12:35 AM, x97mdr 
> wrote:
> >
> > >> OK I changed my test fixture to this:
> >
> > >>[TestMethod]
> > >>public void Can_Add_Variable()
> > >>{
> > >>var relation = new Relation();
> > >> var variable = new Variable();
> > >>relation.AddVariable(variable);
> >
> > >>using (var session = sessionProvider.CreateSession())
> > >>{
> > >>using (var transaction = session.BeginTransaction())
> > >>{
> > >>session.Save(relation);
> > >> transaction.Commit();
> > >>}
> > >>}
> > >>}
> >
> > >> And the relation is saving, but the variable is not. So no cascading
> > >> is happening.  Then I modified the VariableMap class to this:
> >
> > >>public class VariableMap : ClassMap
> > >>{
> > >>public VariableMap()
> > >>{
> > >>Id(x => x.Id);
> > >>References(x => x.ParentRelation)
> > >> .Cascade.All();
> > >>}
> > >>}
> >
> > >> And it works, though my Variable table has three columns Id,
> > >> ParentRelation_id and Relation_id where Relation_id remains NULL.
> >
> > >> Any thoughts?  It's weird that I had to ask the Cascade.All() to the
> > >> References column of the variable when it doesn't appear to be needed
> > >> based on the FirstExample project.  Also, weird that there are three
> > >> columns on the Variable table when I would expect at most 2 columns
> > >> since ParentRelation is set to be t

[fluent-nhib] Re: Overriding auto-mappings to use a composite key

2009-02-12 Thread James Gregory
My surprise was mostly because I thought WithKeyProperty had a string
override, which it doesn't. Damn inconsistency. I'll look at addressing
this.

On Thu, Feb 12, 2009 at 2:44 PM, Jon Kruger  wrote:

>
> I had to add the ActivityTypeId property to make it work.  I would
> rather be able to do this:
>
>public class ActivityMappingOverride :
> IAutoMappingOverride
>{
>public void Override(AutoMap mapping)
>{
>mapping.UseCompositeId()
>.WithKeyProperty(x => x.Id)
> .WithKeyProperty(x => x.ActivityType,
> "ActivityType_id");
>mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> ("Id"));
>mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> ("ActivityType"));
>}
>}
>
> ... and just remove the ActivityTypeId property altogether since I
> shouldn't really need it.
>
> Jon
>
> On Feb 12, 4:06 am, James Gregory  wrote:
> > Hey Jon,
> > Do you actually have a property called ActivityTypeId on Activity? That's
> a
> > little odd, surely it should just be an ActivityType property. Maybe I'm
> > misreading your code.
> >
> > You've definitely struck an unconsidered situation here, but I don't
> think
> > it'd be too difficult to fix (I'll end up just doing the same as what
> you've
> > done, just hidden inside the automapper).
> >
> > On Wed, Feb 11, 2009 at 5:32 PM, Jon Kruger  wrote:
> >
> > > OK, I solved my own problem apparently, but it's not that pretty.  I
> > > added an override class that looks like this:
> >
> > >public class ActivityMappingOverride :
> > > IAutoMappingOverride
> > >{
> > >public void Override(AutoMap mapping)
> > >{
> > >mapping.UseCompositeId()
> > >.WithKeyProperty(x => x.Id)
> > >.WithKeyProperty(x => x.ActivityTypeId,
> > > "ActivityType_id");
> > >mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> > > ("Id"));
> > >mapping.PropertiesMapped.Add(typeof(Activity).GetProperty
> > > ("ActivityTypeId"));
> > >}
> > >}
> >
> > > A couple things that look fishy:
> >
> > > 1) I had to hardcode the column name of ActivityType_id, I wish I
> > > could've said .WithKeyProperty(x => x.ActivityType) and have it figure
> > > out that I want to use the id from ActivityType
> > > 2) I had to tell the mapping class that I already mapped the two
> > > properties or it would make an Id() mapping for Id and a Map() mapping
> > > for ActivityType_id when the automapper ran.  The many-to-one is still
> > > created though (which is good).
> >
>

--~--~-~--~~~---~--~~
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: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-12 Thread James Gregory
You mean an application wide Cascade.All for any relationship? No, not
currently. Good idea though.

On Thu, Feb 12, 2009 at 4:56 PM, Ramana Kumar wrote:

> Thanks James.  Now with the cascade.All, the Saves are working fine.
>
> I guess there is no way to set up "cascade all" for all the Entities that
> references another Entity.
> Ramana
>
> On Thu, Feb 12, 2009 at 3:01 AM, James Gregory wrote:
>
>> Those wiki pages cover how you'd set the cascade.
>> ForTypesThatDeriveFrom(m =>
>> {
>>   m.References(x => Address)
>> .Cascade.All();
>> })
>>
>> On Thu, Feb 12, 2009 at 12:09 AM, Ramana Kumar 
>> wrote:
>>
>>> I will go back home and check the wiki pages.  In the meantime, here is
>>> what I use to save
>>>
>>> [Transaction]
>>> [AcceptVerbs(HttpVerbs.Post)]
>>> public ActionResult Create(Golfer golfer) {
>>> if (golfer.IsValid()) {
>>> golferRepository.SaveOrUpdate(golfer);
>>> TempData["message"] = "The golfer was successfully
>>> created.";
>>> return RedirectToAction("Index");
>>> }
>>> else {
>>>
>>> MvcValidationAdapter.TransferValidationMessagesTo(ViewData.ModelState,
>>> golfer.ValidationResults());
>>> return View();
>>> }
>>> }
>>>
>>> When I put it the thru the debugger, I see that golfer instance has
>>> correct values (from the form) for FirstName, LastName, Email as well as
>>> Address.Addr1, Address.City etc populated correctly.
>>>
>>>  BTW, SaveOrUpdate if fine and when the "Create" method ends (i.e. the
>>> transaction is complete) then I get the exception.  Obviously, because the
>>> flush is thrwoing the exception.
>>>
>>> I still suspect that "cascade" on ManyToOne needs to set to "all", I am
>>> not sure how to do it.
>>> Thanks
>>> Ramana
>>>
>>>
>>> On Wed, Feb 11, 2009 at 2:59 PM, James Gregory 
>>> wrote:
>>>
>>>> Can you show us the code that's actually saving the entities?
>>>> These two wiki pages show the ways you can customise automappings: altering
>>>> entities<http://wiki.fluentnhibernate.org/show/AutoMappingAlteringEntities>
>>>>  and
>>>> mapping 
>>>> overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>.
>>>>
>>>>
>>>>
>>>> On Wed, Feb 11, 2009 at 8:43 PM, Ramana Kumar >>> > wrote:
>>>>
>>>>> No, I did mean Many to One :-)  The Domain Objects are Golfer and
>>>>> Address and many Golfers can share the same Address.  Per James
>>>>> "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
>>>>> one. I am just not sure how to do it thru AutoMap conventions.
>>>>> HTH
>>>>> Ramana
>>>>>
>>>>>
>>>>>  namespace GolfHandicapManager.Core
>>>>> {
>>>>> public class Golfer : Entity
>>>>> {
>>>>> public Golfer() { }
>>>>> [DomainSignature]
>>>>> [NotNullNotEmpty]
>>>>> public virtual string FirstName { get; set; }
>>>>> [DomainSignature]
>>>>> [NotNullNotEmpty]
>>>>> public virtual string LastName { get; set; }
>>>>> [NotNullNotEmpty]
>>>>> public virtual string EmailAddress { get; set; }
>>>>>   public virtual string EmailAddress2 { get; set; }
>>>>>   public virtual string HomePhone { get; set; }
>>>>>   public virtual string CellPhone { get; set; }
>>>>> public virtual Address Address { get; set; }
>>>>> }
>>>>> public class Address : Entity
>>>>> {
>>>>> public Address() { }
>>>>> [DomainSignature]
>>>>>   public virtual string Addr1 { get; set; }
>>>>>   public virtual string Addr2 { get; set; }
>>>>> [DomainSignature]
>>>>>   public virtual string City { get; set; }
>>>>>   public virtual string State { get; set; }
>>>>>   public virtual string Country {

[fluent-nhib] Re: Auto Mapper Enum Types

2009-02-12 Thread James Gregory
I'm not sure why those checks are in there, but I'll investigate when I next
get an opportunity.

On Thu, Feb 12, 2009 at 4:01 PM, Mark Perry wrote:

>
> Here as well in AutoMapComponent.cs
>
> Line 35
>
> if (property.PropertyType.IsEnum || property.GetIndexParameters
> ().Length != 0) continue;
>
>
> After taking both of the checks for "property.PropertyType.IsEnum"
> from the source code and
> running the auto mapper I get the XML outputting correctly.
>
>  type="FluentNHibernate.Mapping.GenericEnumMapper`1
> [[Engineering.Domain.DisplayAs, Engineering.Domain, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
> Version=0.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880">
> 
> 
>
> I guess internally it's using the EnumerationTypeConvention() to do
> the business. Unfortunately I cannot get the automapper to break into
> my ITypeConvention for my Enum.
>
> Also the default is to store as a string in the DB and not an Int
> which it what I would like.
>
> Dunno if any of this helps at all.
>
> Thanks, Mark
>
>
>
>
> On Feb 12, 3:19 pm, Mark Perry  wrote:
> > Seems like the AutoMapper will always ignore Enums from the generated
> > maps:
> >
> > AutoMapper.cs line 57
> >
> > if (!property.PropertyType.IsEnum && property.GetIndexParameters
> > ().Length == 0)
> >
> > Am I right here or should I be doing something else?
> >
> > Mark
> >
> > On Feb 12, 3:02 pm, Mark Perry  wrote:
> >
> > > @Steve
> >
> > > Yeah I get the state thing but all I want is a simple Enum to DB int
> > > mechanism.
> > > From my previous post I don't think this is currently working in the
> > > AutoMapper.
> >
> > > Thanks, Mark
> >
> > > On Feb 12, 2:50 pm, Steven Harman  wrote:
> >
> > > > Mark,
> > > > I like Derick Bailey's approach to solving this - Mapping a State
> Pattern
> > > > with NHibernate:
> http://www.lostechies.com/blogs/derickbailey/archive/2008/11/26/mappi...
> >
> > > > -steve
> >
> > > > //  90% of being smart is knowing what you're dumb at  //
> http://stevenharman.net/
> >
> > > > On Thu, Feb 12, 2009 at 9:12 AM, Mark Perry <
> markperr...@googlemail.com>wrote:
> >
> > > > > Hi
> >
> > > > > Sorry to keep pestering the list like this I feel like I'm being a
> > > > > right pain in the [insert word here].
> >
> > > > > I wanted to have to AutoMapper map one of my properties which is an
> > > > > Enum but it seems as
> > > > > if the AutoMapper just ignores it.
> >
> > > > > I know there is an example on the wiki
> > > > >http://wiki.fluentnhibernate.org/show/AutoMappingTypeConventions
> > > > > but I just want to store my enum as an Int in the Db and have it as
> an
> > > > > enum in my object and not go to the
> > > > > length of implementing IUserType.
> >
> > > > > I think I need to add an ITypeConvention to handle my EnumType and
> add
> > > > > a custom attribute to describe
> > > > > the type of my enum?
> >
> > > > > Am I along the right lines here?
> >
> > > > > Thanks, Mark
> >
>

--~--~-~--~~~---~--~~
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: Possible bug in the method FindMapping of the AutoPersistenceModel class

2009-02-12 Thread James Gregory
Great, good to hear.

On Thu, Feb 12, 2009 at 5:10 PM, Billy  wrote:

>
> Nice work James, I'll include this in the pending #Arch RC.
>
> Billy
>
> On Feb 10, 4:11 pm, James Gregory  wrote:
> > It's official, I've implemented the generic configuration overrides (now
> > called IAutoMappingAlteration instead of Chunk), and the more specific
> > IMappingOverride.
> > You can read about both on the wiki,
> > overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>
> > and
> > configuration alterations<
> http://wiki.fluentnhibernate.org/show/AutoMappingConfigurationAlterat...>
> > .
> >
> > On Tue, Feb 10, 2009 at 2:33 PM, James Gregory  >wrote:
> >
> > > Well the Chunk isn't an override, it doesn't override anything. It
> allows
> > > you to configure the model separately, whether you choose to override
> > > something defined elsewhere is your decision. The chunk allows you to
> > > configure the model in separate "chunks", not in one fell-swoop.
> > > The IMappingOverride on the other hand is an override, hence why it's
> in
> > > the name.
> >
> > > On Tue, Feb 10, 2009 at 2:26 PM, Billy  wrote:
> >
> > >> Heh, I have to admit that was the one thing that I didn't like
> > >> either.  Technical aesthetics. ;)
> >
> > >> Why not a name which describes more what it's purpose is; e.g.,
> > >> ConventionOverrideFor<>, AutoMapOverrideFor<> or something like that?
> >
> > >> Billy
> >
> > >> On Feb 10, 5:00 am, James Gregory  wrote:
> > >> > ...and there's me thinking chunk was an amusing name ;)
> > >> > ConfigPart, Configurer, Config, ConfigUnit, any ideas?
> >
> > >> > On Tue, Feb 10, 2009 at 11:47 AM, Jimit 
> wrote:
> >
> > >> > > That's it. :)
> >
> > >> > > On Feb 10, 11:19 am, James Gregory 
> wrote:
> > >> > > > What's wrong with the chunk? naming?
> >
> > >> > > > On Tue, Feb 10, 2009 at 10:49 AM, Jimit 
> > >> wrote:
> >
> > >> > > > > +1 for the IMappingOverrides option. I ended up doing
> something
> > >> pretty
> > >> > > > > similar that works pretty well so far.:
> >
> > >> > > > > public AutoPersistenceModel
> > >> ApplyMappingOverridesFromAssembly(this
> > >> > > > > AutoPersistenceModel)
> > >> > > > > {
> >
> > >> > > > >IEnumerable mappingOverrides =
> > >> > > > > from type
> in
> > >> > > > > typeof(T).Assembly.GetTypes()
> > >> > > > > where
> > >> > > > > type.IsSubClassOf(typeof (IMappingOverride<>))
> > >> > > > > from
> method in
> > >> > > > > type.GetMethods()
> > >> > > > > where
> > >> > > > > method.DeclaringType == type
> > >> > > > >   &&
> > >> > > > > method.ReturnType == typeof (void)
> > >> > > > >   &&
> > >> > > > > method.GetParameters().Count() == 1 &&
> >
> > >> > > > > method.GetParameters()[0].ParameterType.
> >
> > >> > > > > GetGenericTypeDefinition() ==
> > >> > > > >
> typeof
> > >> > > > > (AutoMap<>)
> > >> > > > > select
> method;
> > >> > > > >mappingOverrides.ForEach(method =>
> > >> > > > >   {
> > >> > > > >   var entityType =
> >
> > >> method.GetParameters()
> > >> > > > > [0].ParameterType.GetGenericArguments()[0];
> > >> > > > >       var autoMapType =
> typeof
> > >> > > > > (AutoMap<>).MakeGenericType(new[

[fluent-nhib] Re: Obscure Mapping Error

2009-02-12 Thread James Gregory
MapEntitiesFromAssembly creates an instance of an AutoPersistenceModel,
so you'd need to do something like this to use multiple assemblies:
var autoMapper1 = AutoPersistenceModel.MapEntitiesFromAssembly();
var autoMapper2 = AutoPersistenceModel.MapEntitiesFromAssembly();

The problem is, that would only map two separate class hierarchies, and not
handle any mixing of the two. I don't think it's currently possible to map
two assemblies as one logical domain. This is something that we should
support though.

On Thu, Feb 12, 2009 at 5:20 PM, Jimit  wrote:

>
> That unfortunately raises other issues for me - all my base classes
> including DomainObject are in another assembly (Core.Common) than the
> one that holds my domain model (Core.Domain). I don't suppose it's
> possible to call MapEntitiesFromAssembly more than once and filter
> it with the same predicate in the Where method? I seem to remember
> MapEntitiesFromAssembly simply saving a reference to the assembly
> for use later in CompileMappings which would mean that calling it
> twice would simply reset the reference.
> What do you think?
>
> On Feb 12, 8:54 am, James Gregory  wrote:
> > Yeah, that makes sense. Currently you shouldn't exclude something set
> with
> > IsBaseType in your Where clause. That being said, the two should probably
> > be equivalent really.
> >
> >
> >
> > On Thu, Feb 12, 2009 at 6:10 AM, Jimit  wrote:
> >
> > > I think I may have found the problem. DomainObject was excluded by my
> > > entity filter in my call to Where on the AutoPersistenceModel (since
> > > it itself is not an entity, just a common base class for both entities
> > > and value objects and thus it doesn't have an Id, I figured no need).
> > > I subsequently did a mapping override using
> > > ForTypesThatDeriveFrom which internally populates an
> > > AutoMap. In CompileMappings however the conditions that
> > > would normally exclude DomainObject from the final mapping (i.e the
> > > checks for shouldInclude and IsBaseType) don't get called for
> > > DomainObject since it was not in the original list of entities to map.
> > > It's AutoMap created by ForTypesThatDeriveFrom is meant
> > > only to be used by MergeMapping to merge with automaps for classes
> > > deriving from DomainObject and instead it went to AddMapping. As a
> > > result it circumvents the checks and ends up getting mapped. Not
> > > having an Id property, Nhibernate doesn't like that and hence the
> > > exception. I haven't actually checked the call stacks to verify this
> > > behaviour - it's all been mental compiler since the realization just
> > > came to me. :) I'll check it out when I'm at work but it seems to be
> > > pointing at a loophole in the CompileMapping logic.
> >
> > > On Feb 10, 10:54 pm, Jimit  wrote:
> > > > This is my test fixture. I configure FNH in the Setup:
> >
> > > > [TestFixture]
> > > > public class PersistenceTests
> > > > {
> > > > #region Setup/Teardown
> >
> > > > [SetUp]
> > > > public void SetUp()
> > > > {
> > > > _sessionFactory = Fluently.Configure()
> > > > .Database(SQLiteConfiguration.Standard.InMemory)
> > > > .Mappings(m => m.AutoMappings.Add(Mapper.Mappings))
> > > > .ExposeConfiguration(cfg => new SchemaExport
> > > > (cfg).Create(true, true))
> > > > .BuildSessionFactory();
> > > > }
> >
> > > > [TearDown]
> > > > public void TearDown()
> > > > {
> > > > _sessionFactory = null;
> > > > }
> >
> > > > #endregion
> >
> > > > private ISessionFactory _sessionFactory;
> >
> > > > [Test]
> > > > public void Can_Map_Orders_To_Database()
> > > > {
> > > > new PersistenceSpecification
> > > > (_sessionFactory.OpenSession())
> > > > .CheckProperty(o => o.Reference, "Order Ref 1")
> > > >   .CheckProperty(o => o.PartsOrdered, 2) /* and so
> > > > on...*/
> > > > .CheckProperty(o => o.PartsReceived, 1);
> > > > }
> >
> > > > }
> >
> > > > Mapper.Mappings is where the Auto

[fluent-nhib] Re: Mapping an enum with DB type as int (sorry for the double posting, if any)

2009-02-12 Thread James Gregory
I believe somebody else raised this earlier, it's on my list of things to
review as soon as I get the chance.
Just FYI both your messages were in the message queue, so I removed your
original one.

On Thu, Feb 12, 2009 at 8:39 PM, blindwillie  wrote:

>
> Hi
>
> I may have been double posting, but I could not find my first mail on
> the list to submit additional information. I apologize if it's just me
> being too impatient.
>
> Well... My former post was about mapping nullable enums, but I now
> find, that this applies to all enums that maps to an int column in the
> DB.
>
> I use the mapping: Map(x => x.EnumType).CustomTypeIs(typeof(int))
>
> It has worked before, but I have now updated to trunk, and now I get
> an NHibernate exception when i get the entity, that says "Cannot parse
> 2 as EnumType".
>
> Any one knows why?
>
> Sincerely, Asger
>
> >
>

--~--~-~--~~~---~--~~
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: Examples.FirstProject - No Inserts to Employee table happening

2009-02-12 Thread James Gregory
Somebody else just raised this exact issue today, I'll investigate asap.
Thanks.

On Thu, Feb 12, 2009 at 9:20 PM, fmorriso  wrote:

>
> I'm running the Examples.FirstProject using Microsoft SQL Server 2008
> Developer Edition and Visual Studio 2008 SP1, .Net Framework 3.5 SP1
> and it does not generate any INSERT's for the Employee table.
>
> The narrative for the example indicates that saving a Store object
> should auto-generate any necessary Employee INSERT's, but the output
> on the console shows only INSERT's for Store, Product and
> StoreProduct.  A SELECT * FROM dbo.[Employee] returns zero rows.
>
> There aren't very many changes needed to switch the example to use SQL
> Server 2008, but perhaps one or more of those changes I made could
> have disabled the automatic generation of Employee INSERT
> statements?   I hate to post tons of code, so if somebody could email
> me to show me how to upload the code, I'd be glad to share it - and
> maybe learn something in the process.
>
> Here's just a small example of a change I made to allow the example to
> use SQL Server 2008.  Hopefully, I didn't mess it up too bad:
>
>/// 
>/// Sets up the required NHibernate session factory
>/// 
>/// ISessionFactory instance
>private static ISessionFactory CreateSessionFactory()
>{
>string connString = GetDatabaseConnectionString();
>Console.WriteLine(connString);
>
>// Use Fluent NHibernate instead of an NHibernate XML
> config file
>return Fluently.Configure()
>.Database(MsSqlConfiguration.MsSql2005
>.ConnectionString(c => c.Is(connString))
>.ShowSql()
>.DefaultSchema("dbo")
>)
>.Mappings(m => m
>  .FluentMappings.AddFromAssemblyOf()
>)
>//WARNING: will DROP/CREATE tables .ExposeConfiguration
> (BuildSchema)
>.BuildSessionFactory();
>}
>
> I built the database myself (so I'm a control freak, sue me) rather
> than end up with weird PK and FK constraint names.
>
> The DDL for the Employee table looks like this:
>
> CREATE TABLE [dbo].[Employee](
>[Id] [int] IDENTITY(1,1) NOT NULL,
>[LastName] [nvarchar](100) NOT NULL,
>[FirstName] [nvarchar](100) NOT NULL,
>[Store_id] [int] NULL,
>  CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
> (
>[Id] ASC
> )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY
> = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
> ) ON [PRIMARY]
>
> GO
>
> ALTER TABLE [dbo].[Employee]  WITH NOCHECK
>ADD  CONSTRAINT [FK_Employee_Store] FOREIGN KEY([Store_id])
>REFERENCES [dbo].[Store] ([Id])
> GO
>
> ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [FK_Employee_Store]
> GO
>
> The DDL for Store looks like this:
>
> CREATE TABLE [dbo].[Store](
>[Id] [int] IDENTITY(1,1) NOT NULL,
>[Name] [nvarchar](100) NOT NULL,
>  CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED
> (
>[Id] ASC
> )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY
> = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
> ) ON [PRIMARY]
>
> GO
>
> >
>

--~--~-~--~~~---~--~~
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: Perhaps we should just push an 0.1 binary out there?

2009-02-13 Thread James Gregory
There's been zero progress on the CI front, people just don't want to talk
to me about it it seems :(
If Chad needs a 0.1 binary, he shall receive. I'll publish one asap
(hopefully tonight).

On Fri, Feb 13, 2009 at 4:55 AM, Paul Batum  wrote:

> Hi All,
>
> Chad is giving us a poke with this post:
>
> http://www.lostechies.com/blogs/chad_myers/archive/2009/02/12/need-advice-teach-nhibernate-with-fluent-nhibernate-or-without.aspx
>
> I appreciate his dilemma, and would like to help. I suggest we push out a
> 0.1 binary release as doing so will let Chad use Fluent NHibernate in his
> article and help publicize the project. I would like to hear opinions on
> this suggestion.
>
> An alternative to releasing an 0.1 version is to make nightlies avaliable
> from a CI server - I know there was discussion of getting Fluent NHibernate
> included in the CodeBetter TeamCity setup. Has that progressed at all?
>
> Paul Batum
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Mapping components

2009-02-13 Thread James Gregory
My bad, that was the incorrect syntax in the wiki; however, I've just
committed a change that should make it work. The syntax in the wiki is now
the recommended one, now that it works.

On Fri, Feb 13, 2009 at 11:03 AM, Mikael  wrote:

>
> Yesterday I created a spike to test out mapping components. Fluent
> Nhibernate's wiki shows the syntax like this:
> # // mapping
> # Component(x => x.Address, c =>
> # {
> #   c.Map(x => x.Number);
> #   c.Map(x => x.Street);
> #   c.WithParentReference(x => x.Resident);
> # });
>
> I couldn't get it to work because of a syntax error so I did little
> googling and found an example of this and the syntax was little
> different. It went like this:
>
> # // mapping
> # Component(x => x.Address, c =>
> # {
> #   c.Map(x => x.Number);
> #   c.Map(x => x.Street);
> #   c.WithParentReference(x => x.Resident);
> # });
>
> And that worked. So is the wiki showing the wrong syntax or am I using
> a older build of the Fluent NHibernate?
>
> >
>

--~--~-~--~~~---~--~~
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: Perhaps we should just push an 0.1 binary out there?

2009-02-13 Thread James Gregory
Lack of access. We don't have a CI system at all. I've used TeamCity before,
so running it shouldn't be a problem... once we have one :)
I've dropped a few emails to the codebetter guys, and Jeremy suggested it
before, but I've not heard anything back.

On Fri, Feb 13, 2009 at 12:59 PM, x97mdr  wrote:

>
> Is the problem with TeamCity a lack of access or knowledge to use it?
> I'm fairly adept with CI systems and would love to help contribute if
> you need a hand setting it up or even someone to needle the CodeBetter
> people to provide access?
>
> On Feb 13, 5:25 am, James Gregory  wrote:
> > There's been zero progress on the CI front, people just don't want to
> talk
> > to me about it it seems :(
> > If Chad needs a 0.1 binary, he shall receive. I'll publish one asap
> > (hopefully tonight).
> >
> > On Fri, Feb 13, 2009 at 4:55 AM, Paul Batum 
> wrote:
> > > Hi All,
> >
> > > Chad is giving us a poke with this post:
> >
> > >http://www.lostechies.com/blogs/chad_myers/archive/2009/02/12/need-ad.
> ..
> >
> > > I appreciate his dilemma, and would like to help. I suggest we push out
> a
> > > 0.1 binary release as doing so will let Chad use Fluent NHibernate in
> his
> > > article and help publicize the project. I would like to hear opinions
> on
> > > this suggestion.
> >
> > > An alternative to releasing an 0.1 version is to make nightlies
> avaliable
> > > from a CI server - I know there was discussion of getting Fluent
> NHibernate
> > > included in the CodeBetter TeamCity setup. Has that progressed at all?
> >
> > > Paul Batum
> >
>

--~--~-~--~~~---~--~~
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: Entity spanning multiple tables

2009-02-13 Thread James Gregory
I don't think that's possible. Your design sounds a little funny to me, it
seems more like Address should be it's own entity and there be a many-to-one
between Customer and Address. Joining two tables into one entity is only
really done when they share a primary key value. I don't think the
underlying NHibernate feature is capable of handling your design.

On Fri, Feb 13, 2009 at 2:57 PM, Craig G  wrote:

>
> We are trying to get the "Entity spanning multiple tables" to work
> with a slightly different scenario from the one in the examples
> http://code.google.com/p/fluent-nhibernate/wiki/Examples, but are
> having a problem trying to define the name of the foreighn key column
> to be used when we perform a select query.
>
> Our schema is as follows:
>
>  table Customer (
>Id int primary key
>Name varchar(100),
>CustomerAddressId int// Different from example
>  )
>
>  table CustomerAddress (
>CustomerAddressId int,   // Different from example
>Address varchar(100)
>  )
>
> The basic difference from the one in the examples is that our foreign
> key is from Customer to CustomerAddress instead of the other way
> around.
>
> Our mapping looks like this:
>
>public CustomerMap()
>{
>Id(x => x.Id);
>Map(x => x.Name);
>WithTable("CustomerAddress", m =>
>{
>m.WithKeyColumn("CustomerAddressId"); // Different
> from example
>m.Map(x => x.Address);
>});
>}
>
> And the resulting SQL query is this:
>
>  SELECT cust.Id, cust.Name, addr.Address
>  FROM cg_temp..Customer cust inner join cg_temp..CustomerAddress
> addr
> on cust.Id=addr.CustomerAddressId
>
> .. the problem is that on the 3rd line 'cust.Id' should be
> 'cust.CustomerAddressId ' i.e.
>   'on cust.CustomerAddressId =addr.CustomerAddressId'.
>
> Any ideas on how I would do this?
>
> >
>

--~--~-~--~~~---~--~~
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] Removal of Framework project

2009-02-13 Thread James Gregory
Guys,
I forgot to mention this the other day when I did it, but just a heads up
that I've nuked the Framework project. I had a cleanout of a load of old
stuff that I'm pretty sure nobody uses, and that left very little in the
Framework project, so I just moved what was left into the main project.

Let me know if I removed anything anyone was using.

James

--~--~-~--~~~---~--~~
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: Entity spanning multiple tables

2009-02-13 Thread James Gregory
Map it as a separate entity then, CustomerAddress.
public class Customer {
  public virtual CustomerAddress Address { get; set;
}

public CustomerMap() {
  References(x => x.Address);
}

On Fri, Feb 13, 2009 at 10:31 PM, Craig G  wrote:

>
> I've been looking at the underlying NHibernate feature and came to the
> same conclusion. Unfortunately we don't have any control over the
> schema because it is a legacy database.
>
> Thanks for the reply James.
> >
>

--~--~-~--~~~---~--~~
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: Can't build the latest version

2009-02-14 Thread James Gregory
What revision are you on? Is your copy from svn? Do you have the svn
commandline tools installed?
Our build script was updated to try to find out the svn revision it's being
built from, and to sign the assemblies with it; however, it looks like
there's a bug when it try's to ask subversion for the revision if you only
have TSVN installed.

I'll try to fix this.

On Sat, Feb 14, 2009 at 9:54 AM, Mikael  wrote:

>
> I updated the Fluent NHibernate to the latest version but I'm now
> having some problems building it. The older version (from ~3rd of
> February) built fine.
>
> When running the Build.bat, I get the following error:
>
> Microsoft (R) Build Engine Version 3.5.30729.1
> [Microsoft .NET Framework, Version 2.0.50727.3053]
> Copyright (C) Microsoft Corporation 2007. All rights reserved.
>
> c:\dev\OSS\fluent-nhibernate\src\CommonAssemblyInfo.cs(4,12): error
> CS0647: Err
> or emitting 'System.Reflection.AssemblyVersionAttribute' attribute --
> 'The vers
> ion specified '0.1.0.' is invalid'
> CSC : warning CS1607: Assembly generation -- The version '0.1.0.'
> specified for
>  the 'product version' is not in the normal
> 'major.minor.build.revision' format
> rake aborted!
>
> Any ideas?
> >
>

--~--~-~--~~~---~--~~
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: Perhaps we should just push an 0.1 binary out there?

2009-02-14 Thread James Gregory
Actually, it's done :)
I spoke to them all last night and we've managed to get it sorted. I'm just
now updating the website to include a link to the downloads.

On Sat, Feb 14, 2009 at 3:58 PM, Chad Myers  wrote:

>
> FYI, Jeremy's out this weekend.   I know they're still fiddling with
> the CI stuff and don't feel it's ready for public consumption yet.
> Perhaps that's why you're being stonewalled -- they can't deal with
> that right now?
>
> From what I understand, they have big plans for this, and I know that
> FNH is one obvious candidate for inclusion and I've dropped hints for
> Fubu as well.
>
> It'll happen -- just not as fast as we would like, perhaps.
>
> -c
>
> On Feb 13, 7:06 am, James Gregory  wrote:
> > Lack of access. We don't have a CI system at all. I've used TeamCity
> before,
> > so running it shouldn't be a problem... once we have one :)
> > I've dropped a few emails to the codebetter guys, and Jeremy suggested it
> > before, but I've not heard anything back.
> >
> > On Fri, Feb 13, 2009 at 12:59 PM, x97mdr 
> wrote:
> >
> > > Is the problem with TeamCity a lack of access or knowledge to use it?
> > > I'm fairly adept with CI systems and would love to help contribute if
> > > you need a hand setting it up or even someone to needle the CodeBetter
> > > people to provide access?
> >
> > > On Feb 13, 5:25 am, James Gregory  wrote:
> > > > There's been zero progress on the CI front, people just don't want to
> > > talk
> > > > to me about it it seems :(
> > > > If Chad needs a 0.1 binary, he shall receive. I'll publish one asap
> > > > (hopefully tonight).
> >
> > > > On Fri, Feb 13, 2009 at 4:55 AM, Paul Batum 
> > > wrote:
> > > > > Hi All,
> >
> > > > > Chad is giving us a poke with this post:
> >
> > > > >
> http://www.lostechies.com/blogs/chad_myers/archive/2009/02/12/need-ad.
> > > ..
> >
> > > > > I appreciate his dilemma, and would like to help. I suggest we push
> out
> > > a
> > > > > 0.1 binary release as doing so will let Chad use Fluent NHibernate
> in
> > > his
> > > > > article and help publicize the project. I would like to hear
> opinions
> > > on
> > > > > this suggestion.
> >
> > > > > An alternative to releasing an 0.1 version is to make nightlies
> > > avaliable
> > > > > from a CI server - I know there was discussion of getting Fluent
> > > NHibernate
> > > > > included in the CodeBetter TeamCity setup. Has that progressed at
> all?
> >
> > > > > Paul Batum
> >
>

--~--~-~--~~~---~--~~
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: Removal of Framework project

2009-02-14 Thread James Gregory
Yeah, I still like that idea. The Framework project would've been more
appropriately named FluentNHibernate.StuffWeDontReallyUse. I think the only
things remaining from there were the SessionSource and
PersistenceSpecification, everything else was unused.

On Sat, Feb 14, 2009 at 4:00 PM, Chad Myers  wrote:

>
> +1.
>
> I still like Jeremy's idea of an NHibernate grab-n'-go packaged
> framework starter. FluentNHibernate.Framework was not that, though.
>
> Of with its csproj!
>
> -c
>
> On Feb 13, 3:16 pm, James Gregory  wrote:
> > Guys,
> > I forgot to mention this the other day when I did it, but just a heads up
> > that I've nuked the Framework project. I had a cleanout of a load of old
> > stuff that I'm pretty sure nobody uses, and that left very little in the
> > Framework project, so I just moved what was left into the main project.
> >
> > Let me know if I removed anything anyone was using.
> >
> > James
> >
>

--~--~-~--~~~---~--~~
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: Altering component maps for AutoPersistenceModel broken in recent changes

2009-02-14 Thread James Gregory
Strange, I'll look into this.

On Sat, Feb 14, 2009 at 5:11 PM, Chris Marisic  wrote:

>
> .ForTypesThatDeriveFrom(autoMap =>
> {
>  autoMap.Component(p => p.Address, addr =>
> {
> addr.Map(c => c.Street, "Address");
> addr.Map(c => c.State, "Region");
> addr.Map(c => c.City, "City");
> addr.Map(c => c.Country, "Country");
> addr.Map(c => c.PostalCode, "PostalCode");
> });
>
> This now results in: NHibernate.MappingException: Duplicate property
> mapping of Address found in StructuredWeb.Domain.Business.Customer
>
> at NHibernate.Mapping.PersistentClass.CheckPropertyDuplication()
> at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
> at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
> at NHibernate.Cfg.Configuration.Validate()
> at NHibernate.Cfg.Configuration.BuildSessionFactory()
> at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
>
> If I revert my FNH dll back to my checked in copy I have in my project
> my tests will pass again.
> >
>

--~--~-~--~~~---~--~~
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: How can I map tables under a specific user

2009-02-14 Thread James Gregory
Each database user is associated with a schema, so that's what you're
actually interested in mapping.
There are two ways to do it, and they're both covered in
schemason
the wiki.

On Sat, Feb 14, 2009 at 7:54 PM, araujoao  wrote:

>
> Hello,
>  How can I map sql server tables under a specific user.
>
>  For example I have the table below, under the user test. How can
> I map that?
>
> CREATE TABLE [test].[Languages](
>[LanguageID] [int] IDENTITY(1,1) NOT NULL,
>[Description] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT
> NULL,
>  CONSTRAINT [PK_Languages] PRIMARY KEY CLUSTERED
> (
>[LanguageID] ASC
> )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
> ) ON [PRIMARY]
>
>
> Thanks,
>
>
> Joao
>
> >
>

--~--~-~--~~~---~--~~
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: Configure database-object

2009-02-15 Thread James Gregory
We don't have official support for the generated property, but there is a
workaround available. As for database-object, not currently; it has been
requested before, so it will get in at some point, I just don't know when.

On Sun, Feb 15, 2009 at 9:08 AM, Martin Nilsson  wrote:

> I want my Order class to have a more user friendly order number and use
> Guid as the entity id. I'm using Castle ActiveRecord so I started this
> thread, http://tinyurl.com/b6ulmz
>
> It seems that the Generated 
> property(Chapter
>  "5.1.9. property") is not supported in AR so I'm thinking of
> switching to NHibernate directly. Is it possible to configure
> database-object with Fluent NH?
>
> From
> http://blog.caraulean.com/2008/08/26/additional-identity-column-with-nhibernate/
>
> The mapping file:
> 
>  
>ALTER TABLE Entity DROP COLUMN Id2
>ALTER TABLE Entity ADD Id2 INT IDENTITY
>  
>  
>ALTER TABLE Entity DROP COLUMN Id2
>  
> 
> >
>

--~--~-~--~~~---~--~~
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: Configure database-object

2009-02-15 Thread James Gregory
That's the workaround for generated, yes.
The request for database-object was made off the list IRC. Any entity that
needs database-object could be mapped using traditional hbm, and the rest
using fluent; obviously that's only useful if there's only a few entities
needing database-object.

Have a look at the fluent
configuration<http://wiki.fluentnhibernate.org/show/FluentConfiguration>
wiki
page, under "Mixed HBM and fluent mappings", to see how to use HBM files
with fluent mappings.

On Sun, Feb 15, 2009 at 9:57 AM, Martin Nilsson  wrote:

> For further references. Regarding the workaround for generated property it
> is probably this thread which James is referring to.
>
> http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/6ad6bf65704c7d4/4ba378f7bb08b444
>
> I found no info about previous requests for database-object. There is no
> work around for this then? Maybe I can have a plain hbm file for the Order
> class and exclude it when configuring with FNH? Maybe that's the work
> around? I want to configure the database in my code so I can create the
> schema (for tests) and don't have to do manual steps in the database.
>
>
>
> On Sun, Feb 15, 2009 at 10:24 AM, James Gregory 
> wrote:
>
>> We don't have official support for the generated property, but there is a
>> workaround available. As for database-object, not currently; it has been
>> requested before, so it will get in at some point, I just don't know when.
>>
>>
>> On Sun, Feb 15, 2009 at 9:08 AM, Martin Nilsson wrote:
>>
>>> I want my Order class to have a more user friendly order number and use
>>> Guid as the entity id. I'm using Castle ActiveRecord so I started this
>>> thread, http://tinyurl.com/b6ulmz
>>>
>>> It seems that the Generated 
>>> property<http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/mapping.html>(Chapter
>>>  "5.1.9. property") is not supported in AR so I'm thinking of
>>> switching to NHibernate directly. Is it possible to configure
>>> database-object with Fluent NH?
>>>
>>> From
>>> http://blog.caraulean.com/2008/08/26/additional-identity-column-with-nhibernate/
>>>
>>> The mapping file:
>>> 
>>>  
>>>ALTER TABLE Entity DROP COLUMN Id2
>>>ALTER TABLE Entity ADD Id2 INT IDENTITY
>>>  
>>>  
>>>ALTER TABLE Entity DROP COLUMN Id2
>>>  
>>> 
>>>
>>>
>>
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
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: sql-type="text" mapping

2009-02-15 Thread James Gregory
What code are you using to build the schema?

On Mon, Feb 16, 2009 at 1:01 AM, Foltz  wrote:

>
> I don't think that's the case.  I am still able to create a text field
> if I use the core-nihibernate schema generation with hbm files.  The
> issue only occurs when I use fluent-nhibernate (both with hbm files
> and fluent mapping).
>
>
> On Feb 15, 6:11 am, Ryan Kelley  wrote:
> > Seems like "Text" was deprecated with SQL2005, you can use .WithLength
> > (1) in your mapping file and it will create nvarchar(max) column.
> >
> > -Ryan
> >
> > On Feb 14, 7:41 am, Foltz  wrote:
> >
> > > hey,
> >
> > > I came across what I think is bug in fluent-nh with the mapping of
> > > text fields (i.e. string-clobs).
> > > To verify that I am using the right technique, I tested this out with
> > > fluent mapping and using fluent-nh to read hbm maps as well.
> >
> > > fluent:
> >
> > >   Map(x => x.Body).CustomSqlTypeIs("text");
> >
> > > hbm:
> >
> > >   
> > > 
> > >   
> >
> > > In both cases, It produces a varchar(100) field in an mssql-2005
> > > database.
> >
> > > I used the same hbm/mapping file with the core-nhibernate schema
> > > generation technique, and it works correctly.
> >
> > > Oddly enough, I tried running the same test in sqlite, and all three
> > > techniques (fluent-map, fluent-hbm and core-hbm) generate the field as
> > > type-text, but also generate another field I'd specified to be a
> > > varchar as text as well, so it looks like both core and fluent have a
> > > bug with sqlite.
> >
> > > Since I've only recently started playing with fluent-nh, and am not
> > > overly familiar with core-nh, I assume that I may be using the wrong
> > > technique.  If it turns out that this IS a bug, I can submit a report
> > > with the test project I used to demonstrate the discrepancy.
> > > Otherwise, if I'm missing some critical step, please let me know.
> >
> > > thx,
> > > foltz
> >
>

--~--~-~--~~~---~--~~
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: Mapping simple datatypes via fluent nhibernate

2009-02-16 Thread James Gregory
Well, that code you gave is correct. Did you say you were mapping a
List? Have you tried an IList?

On Mon, Feb 16, 2009 at 8:20 AM, Tom Warnat  wrote:

>
> Hi,
>
> the WithElement-Option ist not valid.
>
> HasMany(x => x. MyListOfStrings).AsElement("foo") would be my only option.
>
> I get a MySql.Data.MySqlClient.MySqlException: Table 'foo' doesn't exist
> while running this piece of code.
>
>
>
> -Original Message-
> From: fluent-nhibernate@googlegroups.com
> [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
> Sent: Montag, 9. Februar 2009 14:13
> To: fluent-nhibernate@googlegroups.com
> Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate
>
>
> HasMany(x => x.MyListOfStrings)
>  .WithElement("string column name")
>
> This is from memory so it may not be exact.
>
> On 2/9/09, Tom Warnat  wrote:
> >
> > Hi,
> >
> > i've tryed to map a list of string via fluent nhibernate lately and i
> > can't get it to run.
> >
> > So googling for 8 hours on friday i'll take my shoot here.
> >
> > Can anyone tell me to map a simply a List? Furthermore how get
> > fluent nhibernate to automatically create the relation for the list
> > (which is basically my problem)?
> >
> > thanks in advance.
> >
> > >
> >
>
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: triple mapping trouble

2009-02-16 Thread James Gregory
Hi Guido,
Sorry for not replying sooner, I read your post and made note to reply later
and never did!

I've been looking at your schema, and I think there are a few ways you could
make things easier. Have you considered giving act a direct reference to prj,
then using a subclass mapping to create a Coding and a Testing act subclass?

public abstract class Action
{
  public virtual Project Project { get; set; }
}

public class CodingAction : Action {}
public class TestingAction : Action {}

public class ActionMap : ClassMap
{
  public ActionMap()
  {
DiscriminateSubClassesOnColumn("type")
  .SubClass(subclass => { })
  .SubClass(subclass => { });
  }
}

that would make your schema:

create table Action (
  Id int,
  Project_id int,
  type varchar(200)
)

create table Project (
  Id int
)

Where the Action table has an additional type column that specifies which
class the instance is of. So instead of having to deal with multiple tables
for your triple, you could just have it mapped like so:

public Triple()
{
  References(x => x.Project);
  References(x => x.Coding);
  References(x => x.Testing);
}

Where both Coding and Testing are referencing the Action table, rather than
specific TestAction or CodingAction tables. How does that sound?

If you're unsure about what's being mapped here, have a look at
Inheritance
in
the NHibernate docs. I've suggested a Table per class hierarchy.

On Mon, Feb 16, 2009 at 7:57 AM, Guido Ziliotti wrote:

>
> Maybe this example is not that intresting, anyway the main problem
> underling the sample is:
>
> how can I reference a unique key in the referenced table instead of
> the primary key of the referenced table?
>
>
>
> On Fri, Feb 13, 2009 at 4:54 PM, Guido Ziliotti
>  wrote:
> > I would like to ask how to map the sql script attacched to this mail.
> > Thwe script is for MSSQL. This is the piicture -a bit strange, but not
> too much.
> >
> > Entity:
> >
> > Prioject - Table prj, represnts a software pproject.
> > Action  - A step to develop the porject. So the project is it's parent
> object
> >
> > But there are two kind of actions
> >
> > Coding  - Table act_coding  (action_id+project_id)
> > Testing - Table act_testing (action_id+project_id
> >
> > Now the ternary relation. Coding actions and testing actions may be
> related.
> > The relation is many to many but it has to happen inside the scope of a
> Common
> > Parent Project.
> >
> > So this is defined by the "triple" table which is composed by
> >
> > poject, coding, testing
> >
> > and project +coding must find a match in Coding Table, project + testing
> must
> > find a match in testing Table. This is a way to express the fact there is
> > indeed acommon project for the two actions.
> > By the way this is why project_id is not in The common base table Act. I
> had to
> > move it down to enable the foreign key form triple.
> >
> >
> > I would like to build suche tables with Fluent Nhibernate, or at least to
> map
> > them.
> >
> > 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: Mapping simple datatypes via fluent nhibernate

2009-02-16 Thread James Gregory
What's your schema?

On Mon, Feb 16, 2009 at 9:48 AM, Tom Warnat  wrote:

>  I do.
>
>
>
> Class:
>
>
>
> public class Contributor
>
> {
>
> #region Properties
>
>
>
> public virtual int Id { get; set; }
>
>
>
> public virtual string SequenceNumber { get; set; }
>
>
>
> public virtual IList Names { get; set; }
>
>
>
> #endregion
>
>
>
> #region Constructor
>
>
>
> public Contributor()
>
> {
>
> this.SequenceNumber = String.Empty;
>
>
>
> this.Names = new List();
>
> }
>
>
>
> #endregion
>
> }
>
>
>
> Mapping:
>
>
>
> using FluentNHibernate.Mapping;
>
>
>
> public class ContributorMap : ClassMap
>
> {
>
> public ContributorMap()
>
> {
>
> Id(x => x.Id);
>
>
>
> Map(x => x.SequenceNumber);
>
>
>
> HasMany(x => x.Names).AsElement("MyNames"); //WithElement can
> not be found…
>
> }
>
> }
>
>
>
> *From:* fluent-nhibernate@googlegroups.com [mailto:
> fluent-nhibern...@googlegroups.com] *On Behalf Of *James Gregory
> *Sent:* Montag, 16. Februar 2009 10:09
>
> *To:* fluent-nhibernate@googlegroups.com
> *Subject:* [fluent-nhib] Re: Mapping simple datatypes via fluent
> nhibernate
>
>
>
> Well, that code you gave is correct. Did you say you were mapping a *
> List*? Have you tried an *IList*?
>
> On Mon, Feb 16, 2009 at 8:20 AM, Tom Warnat  wrote:
>
>
> Hi,
>
> the WithElement-Option ist not valid.
>
> HasMany(x => x. MyListOfStrings).AsElement("foo") would be my only option.
>
> I get a MySql.Data.MySqlClient.MySqlException: Table 'foo' doesn't exist
> while running this piece of code.
>
>
>
>
> -Original Message-
> From: fluent-nhibernate@googlegroups.com
> [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
> Sent: Montag, 9. Februar 2009 14:13
> To: fluent-nhibernate@googlegroups.com
> Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate
>
>
> HasMany(x => x.MyListOfStrings)
>  .WithElement("string column name")
>
> This is from memory so it may not be exact.
>
> On 2/9/09, Tom Warnat  wrote:
> >
> > Hi,
> >
> > i've tryed to map a list of string via fluent nhibernate lately and i
> > can't get it to run.
> >
> > So googling for 8 hours on friday i'll take my shoot here.
> >
> > Can anyone tell me to map a simply a List? Furthermore how get
> > fluent nhibernate to automatically create the relation for the list
> > (which is basically my problem)?
> >
> > thanks in advance.
> >
> > >
> >
>
>
>
>
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Getting meta data?

2009-02-16 Thread James Gregory
I think Tuna's suggestion is the best option right now, as we don't expose
any of our internals.

On Mon, Feb 16, 2009 at 2:46 PM, Tuna Toksoz  wrote:

> Can't you get from the Configuration?
>
> Tuna Toksöz
> http://tunatoksoz.com
> http://turkiyealt.net
> http://twitter.com/tehlike
>
> Typos included to enhance the readers attention!
>
>
>
>
> On Mon, Feb 16, 2009 at 4:34 PM, Nieve  wrote:
>
>>
>> Hello all,
>>
>> I've been wondering whether there will be a way to get the mapping
>> meta data. I'm currently using nh mapping attribute, which I also use
>> (with the help of reflection) to know what types have lazy properties
>> for example.
>> From what I've seen in the ClassMap class this cannot be done yet.
>> Or can it and I'm blind (or at least short sighted)?
>>
>>
>>
>
> >
>

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

2009-02-16 Thread James Gregory
Is EntityBase excluded from your mappings? Should it be or is it actually a
table?

On Mon, Feb 16, 2009 at 8:28 PM, Adriano  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
> {
>  // ...
>  // common properties
> }
>
>
> class Fund : Asset
> {
>  // ...
>  // common fund properties
> }
>
>
> class EquityFund : Fund
> {
>  // ...
>  // common equity fund properties
> }
>
>
> class FixedIncomeFund : Fund
> {
>  //
>  // common fixed income fund properties
> }
>
>
> class Trade : EntityBase
> {
>  public Asset Asset { get; set; }
> }
>
>
> When I ask NH to generate the schema, the Asset table gets properly
> generated, but fund table also gets generated with the same attributes
> of the Asset table.  I'm using the latest version from the trunk (I
> think it's revision 319).
>
> What am I missing?
> >
>

--~--~-~--~~~---~--~~
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: Combine mapping file to use sql-insert element for stored procedures

2009-02-17 Thread James Gregory
I've never used stored procedures with NHibernate, so I can't comment how
correct your mapping is; but to use hbm mappings with Fluent NHibernate you
need to add them.
Fluently.Configure()
  .Database(configurer)
  .Mappings(m =>
  {
m.FluentMappings.AddFromAssemblyOf();
m.HbmMappings.AddFromAssemblyOf(); // loads the embedded
resources
  })
  .ExposeConfiguration(BuildSchema)
  .BuildSessionFactory();

On Mon, Feb 16, 2009 at 8:42 PM, Relleum  wrote:

>
> I have a User class that is persisted to a User table in the
> database.  I would like to use a stored procedure for insertions,
> since there is some complex logic that happens in the database.
> Since the parameters required by the stored procedure are nowhere
> close to the properties of the User class, I am not quite sure how
> create the nhibernate mappings.
>
> My first inclination is to create a new class called UserCreator with
> parameters that map to the stored procedure one to one.  Then create a
> classmap that creates the mappings for the properties.  Then, for the
> stored procedure part, create a UserCreator.hbm.xml file to add the
>  element that will call the stored procedure:
>
> 
> namespace="Data">
>
>
>EXEC CreateUser @Name = ?, @Pw= ?, @RoleId tinyint =
> 0, @FirstName
> = ?, @LastName = ?, @Phone = ?, @Email = ?
>
>
> 
>
>
> The problem is that inserts don't seem to be using the sql-insert
> override.  It tried to use the standard generated sql and errors with
> "System.Data.SqlClient.SqlException: Invalid object name
> 'UserCreator'"  The UserCreator.hbm.xml Build Action is set to
> EmbeddedResource, and is in the same assembly that is used in the
> SessionFactory configuration:
>
> Fluently.Configure()
>.Database(configurer)
>.Mappings(m => m.FluentMappings
>.AddFromAssemblyOf()
>.ExposeConfiguration(BuildSchema)
>.BuildSessionFactory();
>
> I'm wondering, is this the best way to handle stored procedures that
> don't directly map to a class in your domain?  Secondly, if this is
> the right way, what am I doing wrong that the xml file is not being
> picked up by fluent nhibernate?
>
>
> >
>

--~--~-~--~~~---~--~~
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: Can I get the nh's Configuration instance from FluentConfiguration?

2009-02-17 Thread James Gregory
Why can't you use the ExposeConfiguration method? Some explanation would
help.

On Tue, Feb 17, 2009 at 7:33 AM, Karron Qiu  wrote:

>
> Thank you.
>
> On Tue, Feb 17, 2009 at 3:28 PM, Tuna Toksoz  wrote:
> > Configuration cfg;
> > var fconfig=Fluently.Configure().ExposeConfiguration(x => cfg
> =
> > x);
> > PlayWithCfgHere
> > var sf = fconfig.BuildSessionFactory();
> >
> >
> > Or simple call ExposeConfiguration(Action) to modify/dowhatever
> > using a delegate.
> >
> > Tuna Toksöz
> > http://tunatoksoz.com
> > http://turkiyealt.net
> > http://twitter.com/tehlike
> >
> > Typos included to enhance the readers attention!
> >
> >
> >
> > On Tue, Feb 17, 2009 at 9:22 AM, Karron Qiu  wrote:
> >>
> >> I just want to get the Configuration object from Fluently.Configure().
> >> Or can I pass a Configuration object to Fluently.Configure() ?
> >>
> >> Thanks
> >>
> >> On Tue, Feb 17, 2009 at 3:15 PM, Tuna Toksoz  wrote:
> >> > Fluently.Configure()
> >> >   .Database(/* your database settings */)
> >> >   .Mappings(/* your mappings */)
> >> >   .ExposeConfiguration(/* alter Configuration */) // optional
> >> >   .BuildSessionFactory();
> >> >
> >> > says the post on James blog?
> >> >
> >> > Tuna Toksöz
> >> > http://tunatoksoz.com
> >> > http://turkiyealt.net
> >> > http://twitter.com/tehlike
> >> >
> >> > Typos included to enhance the readers attention!
> >> >
> >> >
> >> >
> >> > On Tue, Feb 17, 2009 at 9:11 AM, Karron Qiu 
> wrote:
> >> >>
> >> >> There is a property in FluentConfiguration, but it is internal...  I
> >> >> want to hold the Configuration in my application because of some
> >> >> reasons. I can't use the ExposeConfiguration method.
> >> >>
> >> >> --
> >> >> Regards,
> >> >> Karron
> >> >>
> >> >>
> >> >
> >> >
> >> > >
> >> >
> >>
> >>
> >>
> >> --
> >> Regards,
> >> Karron
> >>
> >>
> >
> >
> > >
> >
>
>
>
> --
> Regards,
> Karron
>
> >
>

--~--~-~--~~~---~--~~
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: Named queries?

2009-02-17 Thread James Gregory
Nope, but you can mix fluent and hbm mappings, so that'd probably do the
trick. See: Fluent
Configuration


On Mon, Feb 16, 2009 at 4:09 PM, jean.crot...@gmail.com <
jean.crot...@gmail.com> wrote:

>
> Is there anyway to define named queries in the Fluent mappings?
>
> >
>

--~--~-~--~~~---~--~~
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: Primary Key naming

2009-02-17 Thread James Gregory
Yeah, no support for this yet.

On Tue, Feb 17, 2009 at 9:43 AM, Paul Batum  wrote:

> Ahh, I don't think we have support in for this one yet.
>
>
> On Tue, Feb 17, 2009 at 6:48 PM, Guido Ziliotti 
> wrote:
>
>> Not really, actually I am looking for
>> Id(x=>x.Id).WithPrimaryKeyName("PK_CLASS");
>>
>> I admit I am not sure this can be done since basically I started from
>> scratch with FluentNhibernate.
>> By the way I think I'd never started NHibernate without FluentNhibernate.
>> Though I think there are some corners where hbm knowledge might still be
>> necessary, still
>> I am much happier with FluentNhibernate :D
>>
>>
>> On Tue, Feb 17, 2009 at 4:36 AM, Paul Batum  wrote:
>>
>>> I believe you are looking for WithForeignKeyConstraintName().
>>>
>>> Paul Batum
>>>
>>> On Tue, Feb 17, 2009 at 3:28 AM, Guido Ziliotti <
>>> guido.zilio...@gmail.com> wrote:
>>>
 Is there a way to control the Primary Name? I mean the Constraint Name
 not the column?



>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~-~--~~~---~--~~
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: Can I get the nh's Configuration instance from FluentConfiguration?

2009-02-17 Thread James Gregory

Calm it Kermit. I'm not against having a constructor overload, I'll do
that next time I'm in there.

As for exposing the property, I'd prefer not to because it's polluting
the API, but I'm not that fussed. All I wanted to know was why he said
he couldn't use the ExposeConfiguration; not didn't want to, or felt
it was unintuitive, but can't use it.

On 2/17/09, Paul Batum  wrote:
> Just wanted to add that I recognise you can get a reference to it using
> Tuna's trick with the closure but I think its highly unintuitive.
>
> On Tue, Feb 17, 2009 at 9:34 PM, Paul Batum  wrote:
>
>> James, is there a reason you don't want to expose the Configuration? What
>> if someone wants to do something with it after the session factory is
>> built?
>> It seems perfectly reasonable to me for the getter to be public.
>>
>> Also, I wanted to add an overload to Fluently.Configure that takes an
>> existing Configuration object, there was one user that said this would
>> make
>> life much easier for him. Do you have a problem with this?
>>
>>
>> On Tue, Feb 17, 2009 at 9:23 PM, James Gregory
>> wrote:
>>
>>> Why can't you use the ExposeConfiguration method? Some explanation would
>>> help.
>>>
>>>
>>> On Tue, Feb 17, 2009 at 7:33 AM, Karron Qiu  wrote:
>>>
>>>>
>>>> Thank you.
>>>>
>>>> On Tue, Feb 17, 2009 at 3:28 PM, Tuna Toksoz  wrote:
>>>> > Configuration cfg;
>>>> > var fconfig=Fluently.Configure().ExposeConfiguration(x =>
>>>> cfg =
>>>> > x);
>>>> > PlayWithCfgHere
>>>> > var sf = fconfig.BuildSessionFactory();
>>>> >
>>>> >
>>>> > Or simple call ExposeConfiguration(Action) to
>>>> modify/dowhatever
>>>> > using a delegate.
>>>> >
>>>> > Tuna Toksöz
>>>> > http://tunatoksoz.com
>>>> > http://turkiyealt.net
>>>> > http://twitter.com/tehlike
>>>> >
>>>> > Typos included to enhance the readers attention!
>>>> >
>>>> >
>>>> >
>>>> > On Tue, Feb 17, 2009 at 9:22 AM, Karron Qiu 
>>>> wrote:
>>>> >>
>>>> >> I just want to get the Configuration object from
>>>> >> Fluently.Configure().
>>>> >> Or can I pass a Configuration object to Fluently.Configure() ?
>>>> >>
>>>> >> Thanks
>>>> >>
>>>> >> On Tue, Feb 17, 2009 at 3:15 PM, Tuna Toksoz 
>>>> wrote:
>>>> >> > Fluently.Configure()
>>>> >> >   .Database(/* your database settings */)
>>>> >> >   .Mappings(/* your mappings */)
>>>> >> >   .ExposeConfiguration(/* alter Configuration */) // optional
>>>> >> >   .BuildSessionFactory();
>>>> >> >
>>>> >> > says the post on James blog?
>>>> >> >
>>>> >> > Tuna Toksöz
>>>> >> > http://tunatoksoz.com
>>>> >> > http://turkiyealt.net
>>>> >> > http://twitter.com/tehlike
>>>> >> >
>>>> >> > Typos included to enhance the readers attention!
>>>> >> >
>>>> >> >
>>>> >> >
>>>> >> > On Tue, Feb 17, 2009 at 9:11 AM, Karron Qiu 
>>>> wrote:
>>>> >> >>
>>>> >> >> There is a property in FluentConfiguration, but it is internal...
>>>>  I
>>>> >> >> want to hold the Configuration in my application because of some
>>>> >> >> reasons. I can't use the ExposeConfiguration method.
>>>> >> >>
>>>> >> >> --
>>>> >> >> Regards,
>>>> >> >> Karron
>>>> >> >>
>>>> >> >>
>>>> >> >
>>>> >> >
>>>> >> > >
>>>> >> >
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Regards,
>>>> >> Karron
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> > >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Karron
>>>>
>>>>
>>>>
>>>
>>> >>
>>>
>>
>
> >
>

--~--~-~--~~~---~--~~
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: Can I get the nh's Configuration instance from FluentConfiguration?

2009-02-17 Thread James Gregory
Right, the constructor change is in. You can now do this:
var cfg = new Configuration();

Fluently.Configure(cfg)
  .blah();


On Tue, Feb 17, 2009 at 12:00 PM, James Gregory wrote:

> Calm it Kermit. I'm not against having a constructor overload, I'll do
> that next time I'm in there.
>
> As for exposing the property, I'd prefer not to because it's polluting
> the API, but I'm not that fussed. All I wanted to know was why he said
> he couldn't use the ExposeConfiguration; not didn't want to, or felt
> it was unintuitive, but can't use it.
>
> On 2/17/09, Paul Batum  wrote:
> > Just wanted to add that I recognise you can get a reference to it using
> > Tuna's trick with the closure but I think its highly unintuitive.
> >
> > On Tue, Feb 17, 2009 at 9:34 PM, Paul Batum 
> wrote:
> >
> >> James, is there a reason you don't want to expose the Configuration?
> What
> >> if someone wants to do something with it after the session factory is
> >> built?
> >> It seems perfectly reasonable to me for the getter to be public.
> >>
> >> Also, I wanted to add an overload to Fluently.Configure that takes an
> >> existing Configuration object, there was one user that said this would
> >> make
> >> life much easier for him. Do you have a problem with this?
> >>
> >>
> >> On Tue, Feb 17, 2009 at 9:23 PM, James Gregory
> >> wrote:
> >>
> >>> Why can't you use the ExposeConfiguration method? Some explanation
> would
> >>> help.
> >>>
> >>>
> >>> On Tue, Feb 17, 2009 at 7:33 AM, Karron Qiu 
> wrote:
> >>>
> >>>>
> >>>> Thank you.
> >>>>
> >>>> On Tue, Feb 17, 2009 at 3:28 PM, Tuna Toksoz 
> wrote:
> >>>> > Configuration cfg;
> >>>> > var fconfig=Fluently.Configure().ExposeConfiguration(x
> =>
> >>>> cfg =
> >>>> > x);
> >>>> > PlayWithCfgHere
> >>>> > var sf = fconfig.BuildSessionFactory();
> >>>> >
> >>>> >
> >>>> > Or simple call ExposeConfiguration(Action) to
> >>>> modify/dowhatever
> >>>> > using a delegate.
> >>>> >
> >>>> > Tuna Toksöz
> >>>> > http://tunatoksoz.com
> >>>> > http://turkiyealt.net
> >>>> > http://twitter.com/tehlike
> >>>> >
> >>>> > Typos included to enhance the readers attention!
> >>>> >
> >>>> >
> >>>> >
> >>>> > On Tue, Feb 17, 2009 at 9:22 AM, Karron Qiu 
> >>>> wrote:
> >>>> >>
> >>>> >> I just want to get the Configuration object from
> >>>> >> Fluently.Configure().
> >>>> >> Or can I pass a Configuration object to Fluently.Configure() ?
> >>>> >>
> >>>> >> Thanks
> >>>> >>
> >>>> >> On Tue, Feb 17, 2009 at 3:15 PM, Tuna Toksoz 
> >>>> wrote:
> >>>> >> > Fluently.Configure()
> >>>> >> >   .Database(/* your database settings */)
> >>>> >> >   .Mappings(/* your mappings */)
> >>>> >> >   .ExposeConfiguration(/* alter Configuration */) // optional
> >>>> >> >   .BuildSessionFactory();
> >>>> >> >
> >>>> >> > says the post on James blog?
> >>>> >> >
> >>>> >> > Tuna Toksöz
> >>>> >> > http://tunatoksoz.com
> >>>> >> > http://turkiyealt.net
> >>>> >> > http://twitter.com/tehlike
> >>>> >> >
> >>>> >> > Typos included to enhance the readers attention!
> >>>> >> >
> >>>> >> >
> >>>> >> >
> >>>> >> > On Tue, Feb 17, 2009 at 9:11 AM, Karron Qiu  >
> >>>> wrote:
> >>>> >> >>
> >>>> >> >> There is a property in FluentConfiguration, but it is
> internal...
> >>>>  I
> >>>> >> >> want to hold the Configuration in my application because of some
> >>>> >> >> reasons. I can't use the ExposeConfiguration method.
> >>>> >> >>
> >>>> >> >> --
> >>>> >> >> Regards,
> >>>> >> >> Karron
> >>>> >> >>
> >>>> >> >>
> >>>> >> >
> >>>> >> >
> >>>> >> > >
> >>>> >> >
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Regards,
> >>>> >> Karron
> >>>> >>
> >>>> >>
> >>>> >
> >>>> >
> >>>> > >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Regards,
> >>>> Karron
> >>>>
> >>>>
> >>>>
> >>>
> >>> >>
> >>>
> >>
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
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: Primary Key naming

2009-02-17 Thread James Gregory
After some thorough investigation, I'm fairly certain it's not possible to
name PKs with NHibernate, so we're unable to support it either.
I'm going to post a question on the main nhusers mailing list to see if
anyone has any ideas, but I've trawled the schema and done some tests and I
can't find a way to do it. You can name all the other constraints, just not
the primary key.

I guess it's because the primary key is defined inline in the create table
statement, while all other constraints are done as alter table's.

On Tue, Feb 17, 2009 at 10:16 AM, James Gregory wrote:

> Yeah, no support for this yet.
>
>
> On Tue, Feb 17, 2009 at 9:43 AM, Paul Batum  wrote:
>
>> Ahh, I don't think we have support in for this one yet.
>>
>>
>> On Tue, Feb 17, 2009 at 6:48 PM, Guido Ziliotti > > wrote:
>>
>>> Not really, actually I am looking for
>>> Id(x=>x.Id).WithPrimaryKeyName("PK_CLASS");
>>>
>>> I admit I am not sure this can be done since basically I started from
>>> scratch with FluentNhibernate.
>>> By the way I think I'd never started NHibernate without
>>> FluentNhibernate.
>>> Though I think there are some corners where hbm knowledge might still be
>>> necessary, still
>>> I am much happier with FluentNhibernate :D
>>>
>>>
>>> On Tue, Feb 17, 2009 at 4:36 AM, Paul Batum wrote:
>>>
>>>> I believe you are looking for WithForeignKeyConstraintName().
>>>>
>>>> Paul Batum
>>>>
>>>> On Tue, Feb 17, 2009 at 3:28 AM, Guido Ziliotti <
>>>> guido.zilio...@gmail.com> wrote:
>>>>
>>>>> Is there a way to control the Primary Name? I mean the Constraint Name
>>>>> not the column?
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: In the nhib2.1 folder, the version of NHibernate.dll is 2.0.1.4000?

2009-02-17 Thread James Gregory
Officially, we don't support 2.1 currently; we've got some other things
in-house to sort out before we tackle that beast. Fluent NHibernate is
targeted at 2.0.1GA. That being said, we'll accept patches to support 2.1 as
long as: a) they're not nasty horrible hacks and b) they don't confuse users
of 2.0.1 (by revealing features that only work in 2.1).
I suggest you try to work around this problem in your copy of FNH until
we're able to officially support trunk.
On Tue, Feb 17, 2009 at 9:33 PM, Steven Lyons  wrote:

>
> Hi Paul,
>
> There are two different issues. The first was the 2.1 binaries being
> incorrect. Thanks for reverting that change. The second is that some
> SessionSource code from r301 depends on nh 2.0 and so won't compile
> with the proper 2.1 binaries. The problem appears to be that it is
> trying to set ISessionFactory.Dialect at line 38 of
> FluentNHibernate.SessionSource but the Dialect property has been
> removed from ISessionFactory (since June, if I'm reading the log
> correctly).
>
> s.
>
>
>
> On Feb 17, 5:16 am, Paul Batum  wrote:
> > Hi Karron,
> >
> > Looks like Andy accidentally checked in modifications to the nh21 files
> in
> > this  >change.
> >
> > I've reversed the changes.
> >
> > Paul Batum
> >
> > On Tue, Feb 17, 2009 at 8:37 PM, Karron Qiu  wrote:
> >
> > > I copied my own nhibernate dlls  to this folder, but compile failed,
> > > because ISessionFactory doesn't have Dialect now in the nhibernate svn
> > > version, but the SessionSource.cs uses it.
> >
> > > --
> > > Regards,
> > > Karron
>
> >
>

--~--~-~--~~~---~--~~
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: In the nhib2.1 folder, the version of NHibernate.dll is 2.0.1.4000?

2009-02-17 Thread James Gregory
That looks a little bit involved for my liking... ;)
Applied, thanks!

On Tue, Feb 17, 2009 at 10:26 PM, C+++ wrote:

> In fact, it's a simple patch, the way to retrieve the current dialect
> should be changed in the SessionSource ctor to the one used in the
> Initialize method.
>
> Like this:
> -_dialect = _sessionFactory.Dialect;
> +_dialect = Dialect.GetDialect(_configuration.Properties);
>
> Patch is attached
>
> On Tue, Feb 17, 2009 at 10:52 PM, James Gregory 
> wrote:
>
>> Officially, we don't support 2.1 currently; we've got some other things
>> in-house to sort out before we tackle that beast. Fluent NHibernate is
>> targeted at 2.0.1GA. That being said, we'll accept patches to support 2.1 as
>> long as: a) they're not nasty horrible hacks and b) they don't confuse users
>> of 2.0.1 (by revealing features that only work in 2.1).
>> I suggest you try to work around this problem in your copy of FNH until
>> we're able to officially support trunk.
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Bug with CustomType in a Component?

2009-02-18 Thread James Gregory
Sorry, your whole conversation went on while I was asleep apparently. I'll
review this asap.

On Wed, Feb 18, 2009 at 3:58 AM, Brendan Erwin wrote:

> Heh, talking to myself here. :)
> Anyway, I put this issue in the tracker and attached the patch there too.
>
> http://code.google.com/p/fluent-nhibernate/issues/detail?id=117
>
>
> On Feb 17, 2009, at 10:44 PM, Brendan Erwin wrote:
>
> Here is a patch that adds IProperty.HasAlterationFrom and modifies the Enum
> Convention to not stomp existing alterations.
>  existing alterations.zip>
>
> It includes a test for the HasAlterationFrom method but I didn't see how
> the conventions are being tested.
>
>
> On Feb 17, 2009, at 9:59 PM, Brendan Erwin wrote:
>
> Did some stepping and found this:
> PropertyMap.Write()
>
>  public void Write(XmlElement classElement, IMappingVisitor visitor)
> {
> visitor.Conventions.AlterMap(this);
>
> XmlElement element = classElement.AddElement("property")
> .WithAtt("name", _property.Name)
> .WithProperties(_extendedProperties);
>
>
> element.AddElement("column"
> ).WithProperties(_columnProperties);
>
> foreach (var action in _alterations)
> {
> action(element);
> }
> }
>
> The call to visitor.Conventions.AlterMap seems to modify the _alterations
> without regard to the pre-existence of an alteration of the same "type".
>
> Prior to calling that line _alterations contained my one alteration setting
> the IUserType; after calling that line it has 3 alterations:
>
> [0]: {Method = {Void b__6(System.Xml.XmlElement)}}  <---
> The only one that should be here.
> [1]: {Method = {Void b__6(System.Xml.XmlElement)}}
> [2]: {Method = {Void b__c(System.Xml.XmlElement)}}
>
> I'll take a look at modifying the default Enum convention such that it will
> look for existing alterations and, if one exists for either CustomeTypeIs or
> CustomSqlTypeIs then it will ignore the property.
> Does that sound like expected/reasonable behavior?
>
>
> On Feb 17, 2009, at 6:38 PM, Brendan Erwin wrote:
>
> I didn't see anything in the issue list about this so maybe I'm the first
> to notice:
> Given this mapping:
>
> WithTable("Insurance");
>
> ...
>
> Component(x => x.InsuranceCardData, m =>
>{
>...
>m.Map(x =>
> x.PatientRelationshipToInsured,
>
> "RelationshipFlag")
>  .CustomTypeIs(
> typeof(PatientRelationshipToInsuredUserType));
>});
>
>
> I get this HBM:
>
> 
>  assembly="Clearwave.Models" namespace="Clearwave.Models.Encounters">
>   
> ...
> 
>   ...
>type="FluentNHibernate.Mapping.GenericEnumMapper`1[[Models.PatientRelationshipsToInsured,Models,
> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
> Version=0.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880">
> ...
> 
> ...
>   
> 
>
>
> Shouldn't the HBM be referencing my custom type instead of the
> GenericEnumMapper?
>
>
>
>
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Can I get the nh's Configuration instance from FluentConfiguration?

2009-02-18 Thread James Gregory
Thanks Karron, I'd never thought of that situation. I've applied your patch,
good work!

On Wed, Feb 18, 2009 at 3:09 AM, Karron Qiu  wrote:

> Here is my patch for ExposeConfiguration, please have a look.
>
> On Wed, Feb 18, 2009 at 10:12 AM, Karron Qiu  wrote:
> > Sorry for my bad English, that confused you.
> >
> > I have two reasons here.
> >
> > 1. ExposeConfiguration method can't be called many times. It's an
> > delegate , not a list that contains delegates. If I call this method
> > many times, only the last one will be executed. Because I have some
> > plugins for nh initialization, I don't know how many are them at
> > runtime, so I can't mix them in one method. I think that
> > ExposeConfiguration supports many calls will be very helpful. The
> > codes may looks like below.
> >
> >
> > private IList> configAlterations = new
> > List>();
> > public FluentConfiguration ExposeConfiguration(Action
> config)
> >{
> >if(config != null)
> >  configAlterations.Add(config);
> >return this;
> >}
> >
> >
> > public ISessionFactory BuildSessionFactory()
> >{
> >try
> >{
> >mappingCfg.Apply(Configuration);
> >
> >foreach (var configAlteration in configAlterations )
> >configAlteration(Configuration);
> >
> >return Configuration.BuildSessionFactory();
> >}
> >catch (Exception ex)
> >        {
> >throw CreateConfigurationException(ex);
> >}
> >}
> >
> > 2. Yes, I want to use the Configuration object later.  The James's
> > patch solved my problem. thank you.
> >
> >
> >
> > On Tue, Feb 17, 2009 at 8:00 PM, James Gregory 
> wrote:
> >>
> >> Calm it Kermit. I'm not against having a constructor overload, I'll do
> >> that next time I'm in there.
> >>
> >> As for exposing the property, I'd prefer not to because it's polluting
> >> the API, but I'm not that fussed. All I wanted to know was why he said
> >> he couldn't use the ExposeConfiguration; not didn't want to, or felt
> >> it was unintuitive, but can't use it.
> >>
> >> On 2/17/09, Paul Batum  wrote:
> >>> Just wanted to add that I recognise you can get a reference to it using
> >>> Tuna's trick with the closure but I think its highly unintuitive.
> >>>
> >>> On Tue, Feb 17, 2009 at 9:34 PM, Paul Batum 
> wrote:
> >>>
> >>>> James, is there a reason you don't want to expose the Configuration?
> What
> >>>> if someone wants to do something with it after the session factory is
> >>>> built?
> >>>> It seems perfectly reasonable to me for the getter to be public.
> >>>>
> >>>> Also, I wanted to add an overload to Fluently.Configure that takes an
> >>>> existing Configuration object, there was one user that said this would
> >>>> make
> >>>> life much easier for him. Do you have a problem with this?
> >>>>
> >>>>
> >>>> On Tue, Feb 17, 2009 at 9:23 PM, James Gregory
> >>>> wrote:
> >>>>
> >>>>> Why can't you use the ExposeConfiguration method? Some explanation
> would
> >>>>> help.
> >>>>>
> >>>>>
> >>>>> On Tue, Feb 17, 2009 at 7:33 AM, Karron Qiu 
> wrote:
> >>>>>
> >>>>>>
> >>>>>> Thank you.
> >>>>>>
> >>>>>> On Tue, Feb 17, 2009 at 3:28 PM, Tuna Toksoz 
> wrote:
> >>>>>> > Configuration cfg;
> >>>>>> > var fconfig=Fluently.Configure().ExposeConfiguration(x
> =>
> >>>>>> cfg =
> >>>>>> > x);
> >>>>>> > PlayWithCfgHere
> >>>>>> > var sf = fconfig.BuildSessionFactory();
> >>>>>> >
> >>>>>> >
> >>>>>> > Or simple call ExposeConfiguration(Action) to
> >>>>>> modify/dowhatever
> >>>>>> > using a delegate.
> >>>>>> >
> >>>>>> > 

[fluent-nhib] Re: a patch for configuring nh2.1's proxyfactory.factory_class setting

2009-02-18 Thread James Gregory
Thanks Karron, I've applied this.

On Wed, Feb 18, 2009 at 3:21 AM, Karron Qiu  wrote:

> proxyfactory.factory_class is a mandatory configuration in nh2.1 trunk
> version. I create a patch to configure this setting.  Please have a
> look it. Thanks. By the way, I consider if we should set a default
> value for it when fluent nh supports nh2.1, such as
> "NHibernate.ByteCode.Castle.ProxyFactoryFactory,
> NHibernate.ByteCode.Castle". Because Castle is more popular than LinFu
> currently.
>
>
> It looks like below.
>
> +protected const string ProxyFactoryFactoryClassKey =
> "proxyfactory.factory_class";
>
> +
> +public TThisConfiguration ProxyFactoryFactory(string
> proxyFactoryFactoryClass)
> +{
> +_values.Store(ProxyFactoryFactoryClassKey,
> proxyFactoryFactoryClass);
> +return (TThisConfiguration)this;
> +}
>
>
> --
> Regards,
> Karron
>
> >
>

--~--~-~--~~~---~--~~
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: Mapping simple datatypes via fluent nhibernate

2009-02-18 Thread James Gregory
Well, if you're generating your schema then that code you posted should
work. I just ran it and I got:
create table [Contributor] (
  Id INT IDENTITY NOT NULL,
   SequenceNumber NVARCHAR(255) null,
   primary key (Id)
)

create table Names (
  Contributor_id INT not null,
   MyNames NVARCHAR(255) null
)

Which is fine.

Admittedly I'm not using MySql but SQLExpress, perhaps there is a problem
with MySql and the schema generation.

How are you generating your schema?

On Wed, Feb 18, 2009 at 9:58 AM, Tom Warnat  wrote:

>  I don't understand. The schema is generated by code. So the listmapping
> should be creating the table automaticly.
>
>
>
> Mit freundlichen Grüßen,
>
>
>
> Tom Warnat
>
>
>
> Mauve Mailorder Software GmbH & Co KG
>
> Steeler Wasserturm
>
> Laurentiusweg 83
>
> 45276 Essen
>
>
>
> Fon: 0201 437918 0
>
> Fax: 0201 431918 55
>
> E-Mail: war...@mauve.de
>
> E-Mail: supp...@mauve.de (System2)
>
> E-Mail: syst...@mauve.de (System3)
>
> E-Mail: shopsupp...@mauve.de (Shop)
>
> http://www.mauve.eu/
>
>
>
> Amtsgericht Essen, HRA 8514
> Geschäftsführer Christian Mauve
> Ust-Id.DE243763811
> St.Nr.111/5770/1703
>
>
>
> *From:* fluent-nhibernate@googlegroups.com [mailto:
> fluent-nhibern...@googlegroups.com] *On Behalf Of *James Gregory
> *Sent:* Montag, 16. Februar 2009 10:51
>
> *To:* fluent-nhibernate@googlegroups.com
> *Subject:* [fluent-nhib] Re: Mapping simple datatypes via fluent
> nhibernate
>
>
>
> What's your schema?
>
> On Mon, Feb 16, 2009 at 9:48 AM, Tom Warnat  wrote:
>
> I do.
>
>
>
> Class:
>
>
>
> public class Contributor
>
> {
>
> #region Properties
>
>
>
> public virtual int Id { get; set; }
>
>
>
> public virtual string SequenceNumber { get; set; }
>
>
>
> public virtual IList Names { get; set; }
>
>
>
> #endregion
>
>
>
> #region Constructor
>
>
>
> public Contributor()
>
> {
>
> this.SequenceNumber = String.Empty;
>
>
>
> this.Names = new List();
>
> }
>
>
>
> #endregion
>
> }
>
>
>
> Mapping:
>
>
>
> using FluentNHibernate.Mapping;
>
>
>
> public class ContributorMap : ClassMap
>
> {
>
> public ContributorMap()
>
> {
>
> Id(x => x.Id);
>
>
>
> Map(x => x.SequenceNumber);
>
>
>
> HasMany(x => x.Names).AsElement("MyNames"); //WithElement can
> not be found…
>
> }
>
> }
>
>
>
> *From:* fluent-nhibernate@googlegroups.com [mailto:
> fluent-nhibern...@googlegroups.com] *On Behalf Of *James Gregory
> *Sent:* Montag, 16. Februar 2009 10:09
>
>
> *To:* fluent-nhibernate@googlegroups.com
> *Subject:* [fluent-nhib] Re: Mapping simple datatypes via fluent
> nhibernate
>
>
>
> Well, that code you gave is correct. Did you say you were mapping a *
> List*? Have you tried an *IList*?
>
> On Mon, Feb 16, 2009 at 8:20 AM, Tom Warnat  wrote:
>
>
> Hi,
>
> the WithElement-Option ist not valid.
>
> HasMany(x => x. MyListOfStrings).AsElement("foo") would be my only option.
>
> I get a MySql.Data.MySqlClient.MySqlException: Table 'foo' doesn't exist
> while running this piece of code.
>
>
>
>
> -Original Message-
> From: fluent-nhibernate@googlegroups.com
> [mailto:fluent-nhibern...@googlegroups.com] On Behalf Of James Gregory
> Sent: Montag, 9. Februar 2009 14:13
> To: fluent-nhibernate@googlegroups.com
> Subject: [fluent-nhib] Re: Mapping simple datatypes via fluent nhibernate
>
>
> HasMany(x => x.MyListOfStrings)
>  .WithElement("string column name")
>
> This is from memory so it may not be exact.
>
> On 2/9/09, Tom Warnat  wrote:
> >
> > Hi,
> >
> > i've tryed to map a list of string via fluent nhibernate lately and i
> > can't get it to run.
> >
> > So googling for 8 hours on friday i'll take my shoot here.
> >
> > Can anyone tell me to map a simply a List? Furthermore how get
> > fluent nhibernate to automatically create the relation for the list
> > (which is basically my problem)?
> >
> > thanks in advance.
> >
> > >
> >
>
>
>
>
>
>
>
>
>
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Mapping simple datatypes via fluent nhibernate

2009-02-18 Thread James Gregory
I've just installed MySql 5.1 and there isn't an issue, I ran the exact same
code and it produced the same schema as I posted above.
What version of MySql are you running on?
How are you creating your schema?
What is the exact exception you're getting?

On Wed, Feb 18, 2009 at 10:57 AM, James Gregory wrote:

> Well, if you're generating your schema then that code you posted should
> work. I just ran it and I got:
> create table [Contributor] (
>   Id INT IDENTITY NOT NULL,
>SequenceNumber NVARCHAR(255) null,
>primary key (Id)
> )
>
> create table Names (
>   Contributor_id INT not null,
>MyNames NVARCHAR(255) null
> )
>
> Which is fine.
>
> Admittedly I'm not using MySql but SQLExpress, perhaps there is a problem
> with MySql and the schema generation.
>
> How are you generating your schema?
>
> On Wed, Feb 18, 2009 at 9:58 AM, Tom Warnat  wrote:
>
>>  I don't understand. The schema is generated by code. So the listmapping
>> should be creating the table automaticly.
>>
>>
>>
>> Mit freundlichen Grüßen,
>>
>>
>>
>> Tom Warnat
>>
>>
>>
>> Mauve Mailorder Software GmbH & Co KG
>>
>> Steeler Wasserturm
>>
>> Laurentiusweg 83
>>
>> 45276 Essen
>>
>>
>>
>> Fon: 0201 437918 0
>>
>> Fax: 0201 431918 55
>>
>> E-Mail: war...@mauve.de
>>
>> E-Mail: supp...@mauve.de (System2)
>>
>> E-Mail: syst...@mauve.de (System3)
>>
>> E-Mail: shopsupp...@mauve.de (Shop)
>>
>> http://www.mauve.eu/
>>
>>
>>
>> Amtsgericht Essen, HRA 8514
>> Geschäftsführer Christian Mauve
>> Ust-Id.DE243763811
>> St.Nr.111/5770/1703
>>
>>
>>
>> *From:* fluent-nhibernate@googlegroups.com [mailto:
>> fluent-nhibern...@googlegroups.com] *On Behalf Of *James Gregory
>> *Sent:* Montag, 16. Februar 2009 10:51
>>
>> *To:* fluent-nhibernate@googlegroups.com
>> *Subject:* [fluent-nhib] Re: Mapping simple datatypes via fluent
>> nhibernate
>>
>>
>>
>> What's your schema?
>>
>> On Mon, Feb 16, 2009 at 9:48 AM, Tom Warnat  wrote:
>>
>> I do.
>>
>>
>>
>> Class:
>>
>>
>>
>> public class Contributor
>>
>> {
>>
>> #region Properties
>>
>>
>>
>> public virtual int Id { get; set; }
>>
>>
>>
>> public virtual string SequenceNumber { get; set; }
>>
>>
>>
>> public virtual IList Names { get; set; }
>>
>>
>>
>> #endregion
>>
>>
>>
>> #region Constructor
>>
>>
>>
>> public Contributor()
>>
>>     {
>>
>> this.SequenceNumber = String.Empty;
>>
>>
>>
>> this.Names = new List();
>>
>> }
>>
>>
>>
>> #endregion
>>
>> }
>>
>>
>>
>> Mapping:
>>
>>
>>
>> using FluentNHibernate.Mapping;
>>
>>
>>
>> public class ContributorMap : ClassMap
>>
>> {
>>
>> public ContributorMap()
>>
>> {
>>
>> Id(x => x.Id);
>>
>>
>>
>> Map(x => x.SequenceNumber);
>>
>>
>>
>> HasMany(x => x.Names).AsElement("MyNames"); //WithElement can
>> not be found…
>>
>> }
>>
>> }
>>
>>
>>
>> *From:* fluent-nhibernate@googlegroups.com [mailto:
>> fluent-nhibern...@googlegroups.com] *On Behalf Of *James Gregory
>> *Sent:* Montag, 16. Februar 2009 10:09
>>
>>
>> *To:* fluent-nhibernate@googlegroups.com
>> *Subject:* [fluent-nhib] Re: Mapping simple datatypes via fluent
>> nhibernate
>>
>>
>>
>> Well, that code you gave is correct. Did you say you were mapping a *
>> List*? Have you tried an *IList*?
>>
>> On Mon, Feb 16, 2009 at 8:20 AM, Tom Warnat  wrote:
>>
>>
>> Hi,
>>
>> the WithElement-Option ist not valid.
>>
>> HasMany(x => x. MyListOfStrings).AsElement("foo") would be my only option.
>>
>> I get a MySql.Data.MySqlClient.MySqlException: Table 'foo' doesn't exist
>> while running this piece of code.
>>
>>
>>
>>
>> -Original Message-
>> From: fluent-nhibernate@googlegroups.com
>> [mailto:fluent-nhi

[fluent-nhib] Re: Auto Mapper Enum Types

2009-02-18 Thread James Gregory
Well, that line you highlighted in AutoMapper doesn't make any sense.
Removing it allows the automapper to map Enums; however, the recommended
behavior in NHibernate is to map enums as strings, and that's what the
automapper does.
If you really must use enums as ints, then you'll need to manually set the
type attribute on the property. I've updated the enum convention to ignore
any enum properties that already have their type set.

Map(x => x.MyEnum)
  .SetAttribute("type", "Int32");

On Wed, Feb 18, 2009 at 9:17 AM, Mark Perry wrote:

>
> James
>
> Have you had any ideas on this one yet?
>
> Mark
>
> On Feb 13, 3:07 pm, Mark Perry  wrote:
> > James
> >
> > Is there anything I can do to help you out further?
> >
> > Mark
> >
> > On Feb 12, 5:51 pm, James Gregory  wrote:
> >
> > > I'm not sure why those checks are in there, but I'll investigate when I
> next
> > > get an opportunity.
> >
> > > On Thu, Feb 12, 2009 at 4:01 PM, Mark Perry <
> markperr...@googlemail.com>wrote:
> >
> > > > Here as well in AutoMapComponent.cs
> >
> > > > Line 35
> >
> > > > if (property.PropertyType.IsEnum || property.GetIndexParameters
> > > > ().Length != 0) continue;
> >
> > > > After taking both of the checks for "property.PropertyType.IsEnum"
> > > > from the source code and
> > > > running the auto mapper I get the XML outputting correctly.
> >
> > > >  > > > type="FluentNHibernate.Mapping.GenericEnumMapper`1
> > > > [[Engineering.Domain.DisplayAs, Engineering.Domain, Version=1.0.0.0,
> > > > Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
> > > > Version=0.1.0.0, Culture=neutral, PublicKeyToken=8aa435e3cb308880">
> > > > 
> > > > 
> >
> > > > I guess internally it's using the EnumerationTypeConvention() to do
> > > > the business. Unfortunately I cannot get the automapper to break into
> > > > my ITypeConvention for my Enum.
> >
> > > > Also the default is to store as a string in the DB and not an Int
> > > > which it what I would like.
> >
> > > > Dunno if any of this helps at all.
> >
> > > > Thanks, Mark
> >
> > > > On Feb 12, 3:19 pm, Mark Perry  wrote:
> > > > > Seems like the AutoMapper will always ignore Enums from the
> generated
> > > > > maps:
> >
> > > > > AutoMapper.cs line 57
> >
> > > > > if (!property.PropertyType.IsEnum && property.GetIndexParameters
> > > > > ().Length == 0)
> >
> > > > > Am I right here or should I be doing something else?
> >
> > > > > Mark
> >
> > > > > On Feb 12, 3:02 pm, Mark Perry  wrote:
> >
> > > > > > @Steve
> >
> > > > > > Yeah I get the state thing but all I want is a simple Enum to DB
> int
> > > > > > mechanism.
> > > > > > From my previous post I don't think this is currently working in
> the
> > > > > > AutoMapper.
> >
> > > > > > Thanks, Mark
> >
> > > > > > On Feb 12, 2:50 pm, Steven Harman  wrote:
> >
> > > > > > > Mark,
> > > > > > > I like Derick Bailey's approach to solving this - Mapping a
> State
> > > > Pattern
> > > > > > > with NHibernate:
> > > >
> http://www.lostechies.com/blogs/derickbailey/archive/2008/11/26/mappi...
> >
> > > > > > > -steve
> >
> > > > > > > //  90% of being smart is knowing what you're dumb at
>  //
> > > >http://stevenharman.net/
> >
> > > > > > > On Thu, Feb 12, 2009 at 9:12 AM, Mark Perry <
> > > > markperr...@googlemail.com>wrote:
> >
> > > > > > > > Hi
> >
> > > > > > > > Sorry to keep pestering the list like this I feel like I'm
> being a
> > > > > > > > right pain in the [insert word here].
> >
> > > > > > > > I wanted to have to AutoMapper map one of my properties which
> is an
> > > > > > > > Enum but it seems as
> > > > > > > > if the AutoMapper just ignores it.
> >
> > > > > > > > I know there is an example on the wiki
> > > > > > > >
> http://wiki.fluentnhibernate.org/show/AutoMappingTypeConventions
> > > > > > > > but I just want to store my enum as an Int in the Db and have
> it as
> > > > an
> > > > > > > > enum in my object and not go to the
> > > > > > > > length of implementing IUserType.
> >
> > > > > > > > I think I need to add an ITypeConvention to handle my
> EnumType and
> > > > add
> > > > > > > > a custom attribute to describe
> > > > > > > > the type of my enum?
> >
> > > > > > > > Am I along the right lines here?
> >
> > > > > > > > Thanks, Mark
> >
>

--~--~-~--~~~---~--~~
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: Auto Mapper Enum Types

2009-02-18 Thread James Gregory
CustomTypeIs is for specifying IUserTypes, so no that wouldn't work.
Although perhaps I should remove that limitation and make CustomTypeIs just
be for any type.

On Wed, Feb 18, 2009 at 1:27 PM, blindwillie  wrote:

>
> Shouldn't it be possible to do it like this:
>
> Map(x => x.MyEnum).CustomTypeIs(typeof(int));
>
> Because such line seems to be ignored right now. I don't know if
> removing the "highlighted" line in the automapper will change that?
>
> /Asger
>
> On Feb 18, 2:23 pm, James Gregory  wrote:
> > Well, that line you highlighted in AutoMapper doesn't make any sense.
> > Removing it allows the automapper to map Enums; however, the recommended
> > behavior in NHibernate is to map enums as strings, and that's what the
> > automapper does.
> > If you really must use enums as ints, then you'll need to manually set
> the
> > type attribute on the property. I've updated the enum convention to
> ignore
> > any enum properties that already have their type set.
> >
> > Map(x => x.MyEnum)
> >   .SetAttribute("type", "Int32");
> >
> > On Wed, Feb 18, 2009 at 9:17 AM, Mark Perry  >wrote:
> >
> >
> >
> > > James
> >
> > > Have you had any ideas on this one yet?
> >
> > > Mark
> >
> > > On Feb 13, 3:07 pm, Mark Perry  wrote:
> > > > James
> >
> > > > Is there anything I can do to help you out further?
> >
> > > > Mark
> >
> > > > On Feb 12, 5:51 pm, James Gregory  wrote:
> >
> > > > > I'm not sure why those checks are in there, but I'll investigate
> when I
> > > next
> > > > > get an opportunity.
> >
> > > > > On Thu, Feb 12, 2009 at 4:01 PM, Mark Perry <
> > > markperr...@googlemail.com>wrote:
> >
> > > > > > Here as well in AutoMapComponent.cs
> >
> > > > > > Line 35
> >
> > > > > > if (property.PropertyType.IsEnum || property.GetIndexParameters
> > > > > > ().Length != 0) continue;
> >
> > > > > > After taking both of the checks for
> "property.PropertyType.IsEnum"
> > > > > > from the source code and
> > > > > > running the auto mapper I get the XML outputting correctly.
> >
> > > > > >  > > > > > type="FluentNHibernate.Mapping.GenericEnumMapper`1
> > > > > > [[Engineering.Domain.DisplayAs, Engineering.Domain,
> Version=1.0.0.0,
> > > > > > Culture=neutral, PublicKeyToken=null]], FluentNHibernate,
> > > > > > Version=0.1.0.0, Culture=neutral,
> PublicKeyToken=8aa435e3cb308880">
> > > > > > 
> > > > > > 
> >
> > > > > > I guess internally it's using the EnumerationTypeConvention() to
> do
> > > > > > the business. Unfortunately I cannot get the automapper to break
> into
> > > > > > my ITypeConvention for my Enum.
> >
> > > > > > Also the default is to store as a string in the DB and not an Int
> > > > > > which it what I would like.
> >
> > > > > > Dunno if any of this helps at all.
> >
> > > > > > Thanks, Mark
> >
> > > > > > On Feb 12, 3:19 pm, Mark Perry 
> wrote:
> > > > > > > Seems like the AutoMapper will always ignore Enums from the
> > > generated
> > > > > > > maps:
> >
> > > > > > > AutoMapper.cs line 57
> >
> > > > > > > if (!property.PropertyType.IsEnum &&
> property.GetIndexParameters
> > > > > > > ().Length == 0)
> >
> > > > > > > Am I right here or should I be doing something else?
> >
> > > > > > > Mark
> >
> > > > > > > On Feb 12, 3:02 pm, Mark Perry 
> wrote:
> >
> > > > > > > > @Steve
> >
> > > > > > > > Yeah I get the state thing but all I want is a simple Enum to
> DB
> > > int
> > > > > > > > mechanism.
> > > > > > > > From my previous post I don't think this is currently working
> in
> > > the
> > > > > > > > AutoMapper.
> >
> > > > > > > > Thanks, Mark
> >
> > > > > > > > On Feb 12, 2:50 pm, Steven Harman 
> wrote:
> >
> > 

[fluent-nhib] Re: On-to-many problem

2009-02-18 Thread James Gregory
An almost exact duplicate of this question was asked on StackOverflow
yesterday, which I answered.
http://stackoverflow.com/questions/554674/fluent-nhibernate-one-to-many-uni-directional-mapping


On Wed, Feb 18, 2009 at 2:23 PM, Blee  wrote:

>
> I'm afraid that I'm having a similar problem, except that I'm using
> the
> automap.  To get around it, for the time being, I just made the FK
> nullable in the database.  All of the values are saved and no error.
> If I find a better solution, I'll let you know.
>
> On Feb 17, 2:38 am, BjartN  wrote:
> > I have a Vessel object that has a one-to-many relationship with a
> > VesselDetail object. When I add a VesselDetail object to the Vessel
> > object and try to save the Vessel object, it seems NHibernate does not
> > add the foreign key when inserting the VesselDetail object.
> >
> > Where am I going wrong here ? I just cannot figure it out. Guess Im
> > missing some nhibernate / fluent nhibernate skillz here:
> >
> > Error message:
> >
> BDN.FindVessel.Tests.Integration.NhibernateRepositoryTests.SaveVessel_ShouldAddDetailsToDb_WhenAddedToEntity:
> > NHibernate.Exceptions.GenericADOException : could not insert:
> > [BDN.FindVessel.Domain.VesselDetail][SQL: INSERT INTO BoatsDetails
> > (SaftyGear, OtherMachineryAndGear, Material, Size, Various,
> > TranslatorId, SpeenAndConsumption, MainMachinery, Created, Class,
> > Capasities, Culture, Interior, Electronics, DeckGear) VALUES
> > (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); select SCOPE_IDENTITY
> > ()]
> >   > System.Data.SqlClient.SqlException : Cannot insert the value
> > NULL into column 'BoatId', table 'FindVesselTest.dbo.BoatsDetails';
> > column does not allow nulls. INSERT fails.
> > The statement has been terminated.
> >
> > public class Vessel
> > {
> > public virtual int BoatId { get; set; }
> > public virtual IList Details { get; set; }
> > //...
> >
> > }
> >
> > public class VesselDetail
> > {
> > public virtual int VesselDetailId { get; set; }
> > //some other properties
> > //..
> >
> > }
> >
> > public class VesselMap: ClassMap
> > {
> > public VesselMap()
> > {
> > WithTable("Boats");
> >
> > Id(x => x.BoatId, "Id");
> >
> > //..
> >
> > HasMany(x => x.Details)
> > .WithKeyColumn("BoatId") //foreign key in the BoatsDetails
> > table
> > .Cascade.All();
> > }
> >
> > }
> >
> > public class VesselDetailMap:ClassMap
> > {
> >   public VesselDetailMap()
> >   {
> >   WithTable("BoatsDetails");
> >
> >   Id(x => x.VesselDetailId, "Id");
> >
> >   //...
> >   }
> >
> > }
>
> >
>

--~--~-~--~~~---~--~~
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: Mapping simple datatypes via fluent nhibernate

2009-02-18 Thread James Gregory
I'm still not able to reproduce this.

It's recommended to follow the Fluent
Configuration<http://wiki.fluentnhibernate.org/show/FluentConfiguration>approach,
rather than using the SessionSource. Have a look at Schema
Generation <http://wiki.fluentnhibernate.org/show/SchemaGeneration> to see
how I do it.
That being said, the SessionSource was using an old way of generating the
schema. I've updated it to use the NHibernate SchemaExport tool. Let me know
if that makes any difference.

There's also now an override to BuildSchema that takes a boolean, when true
it'll make NHibernate output the create script to the console. Combine that
with ShowSql in your database configuration and you'll be able to see
everything NHibernate sends to mysql.

On Wed, Feb 18, 2009 at 1:48 PM, Tom Warnat  wrote:

>  I'm using MySQL 5.0.74 enterprise. A colleague at work tested it with 5.1
> and got the same results. Works with MS SQL 2005 though.
>
>
>
> SQL:
>
>
>
>
> create table `Contributor` (ContributorID INTEGER NOT NULL AUTO_INCREMENT, 
> SequenceNumberWithinRole VARCHAR(255), PersonNameInverted VARCHAR(255), 
> SequenceNumber VARCHAR(255), ContributorRole VARCHAR(255), primary key 
> (ContributorID))
>
> create table libri_names (Contributor_id INTEGER not null, Name VARCHAR(255))
>
> alter table libri_names add index (Contributor_id), add constraint 
> FK597345084712895B foreign key (Contributor_id) references `Contributor` 
> (ContributorID)
> [18.02.2009 14:39:57] - Executing command QUERY with text ='SHOW VARIABLES'
> [18.02.2009 14:39:57] - Executing command QUERY with text ='SHOW COLLATION'
>
> [18.02.2009 14:39:57] - Executing command QUERY with text ='SET NAMES 
> utf8;SET character_set_results=NULL'
> [18.02.2009 14:39:57] - Executing command QUERY with text ='
> alter table libri_names  drop foreign key FK597345084712895B
> '
>
>
>
> Exception:
>
>
>
>
> MySql.Data.MySqlClient.MySqlException: Table 'libri.libri_names' doesn't exist
>
> at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
> at
>
> MySql.Data.MySqlClient.NativeDriver.ReadResult(ref UInt64 affectedRows,
> ref Int64 lastInsertId)
> at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
> at
>
> MySql.Data.MySqlClient.MySqlDataReader.NextResult()
> at
>
> MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior
> )
> at
>
> MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
> at
>
> FluentNHibernate.SessionSource.executeScripts(IEnumerable`1 scripts,
> IDbConnection connection) in
>
> C:\c#
>
> Projekte\FluentNHibernate\src\FluentNHibernate\SessionSource.cs: line 83
> at
>
> FluentNHibernate.SessionSource.BuildSchema(ISession session) in C:\c#
>
> Projekte\FluentNHibernate\src\FluentNHibernate\SessionSource.cs: line 71
> at
>
> Mauve.LibriInterface.DataAccess.Tests.MapTests.SetupContext()
>
> in MapTests.cs: line 34
>
>
>
> Test-Code:
>
>
>
> [TestFixture]
>
> public class MapTests
>
> {
>
> private SessionSource SessionSource { get; set; }
>
>
>
> private ISession Session { get; set; }
>
>
>
> [SetUp]
>
> public void SetupContext()
>
> {
>
> this.SessionSource = new SessionSource(new TestModel());
>
>
>
> this.Session = SessionSource.CreateSession();
>
>
>
> string[] strings = this
> .SessionSource.Configuration.GenerateSchemaCreationScript(SessionSource.Dialect);
>
>
>
> foreach (string s in strings)
>
> {
>
> Trace.WriteLine(s);
>
> }
>
>
>
> this.SessionSource.BuildSchema(Session);
>
>
>
> this.Session.Clear();
>
> }
>
>
>
> [TearDown]
>
> public void TearDownContext()
>
> {
>
> this.Session.Close();
>
>
>
> this.Session.Dispose();
>
> }
>
>
>
> [Test]
>
> public void Contributor_Should_Be_Created_Correctly()
>
> {
>
> var contributor = new Contributor();
>
>
>
> Session.Save(contributor);
>
> }
>
> }
>
>
>
> The problem seems to be that the schema creation tries to drop a foreign
> key on an non existing table. The code works fine if the table is created
> first but not if you try to run it on an empty database.
>
>
>
> Is there an easy way to get the sql created by fluent nhibernate? My
> co-worker created some properties for dia

[fluent-nhib] Re: Many to One AutoMapping - object references an unsaved transient instance - save the transient instance before flushing:

2009-02-18 Thread James Gregory
I'm currently working on a big rewrite of conventions that should drop over
the next few days, once that arrives we'll be able to support the scenario
you speak of.

On Fri, Feb 13, 2009 at 1:28 AM, Brendan Erwin wrote:

> Wait, wouldn't that cause "circular cascades"? (a problem I think I have
> but have yet to get the opportunity to fix...)
>
>
> On Feb 12, 2009, at 12:47 PM, James Gregory 
> wrote:
>
> You mean an application wide Cascade.All for any relationship? No, not
> currently. Good idea though.
>
> On Thu, Feb 12, 2009 at 4:56 PM, Ramana Kumar < 
> ramana.r.ku...@gmail.com> wrote:
>
>> Thanks James.  Now with the cascade.All, the Saves are working fine.
>>
>> I guess there is no way to set up "cascade all" for all the Entities that
>> references another Entity.
>> Ramana
>>
>> On Thu, Feb 12, 2009 at 3:01 AM, James Gregory 
>> wrote:
>>
>>> Those wiki pages cover how you'd set the cascade.
>>> ForTypesThatDeriveFrom(m =>
>>> {
>>>   m.References(x => Address)
>>> .Cascade.All();
>>> })
>>>
>>> On Thu, Feb 12, 2009 at 12:09 AM, Ramana Kumar <
>>> ramana.r.ku...@gmail.com> wrote:
>>>
>>>> I will go back home and check the wiki pages.  In the meantime, here is
>>>> what I use to save
>>>>
>>>> [Transaction]
>>>> [AcceptVerbs(HttpVerbs.Post)]
>>>> public ActionResult Create(Golfer golfer) {
>>>> if (golfer.IsValid()) {
>>>> golferRepository.SaveOrUpdate(golfer);
>>>> TempData["message"] = "The golfer was successfully
>>>> created.";
>>>> return RedirectToAction("Index");
>>>> }
>>>> else {
>>>>
>>>> MvcValidationAdapter.TransferValidationMessagesTo(ViewData.ModelState,
>>>> golfer.ValidationResults());
>>>> return View();
>>>> }
>>>> }
>>>>
>>>> When I put it the thru the debugger, I see that golfer instance has
>>>> correct values (from the form) for FirstName, LastName, Email as well as
>>>> Address.Addr1, Address.City etc populated correctly.
>>>>
>>>>  BTW, SaveOrUpdate if fine and when the "Create" method ends (i.e. the
>>>> transaction is complete) then I get the exception.  Obviously, because the
>>>> flush is thrwoing the exception.
>>>>
>>>> I still suspect that "cascade" on ManyToOne needs to set to "all", I am
>>>> not sure how to do it.
>>>> Thanks
>>>> Ramana
>>>>
>>>>
>>>> On Wed, Feb 11, 2009 at 2:59 PM, James Gregory >>> > wrote:
>>>>
>>>>> Can you show us the code that's actually saving the entities?
>>>>> These two wiki pages show the ways you can customise automappings: 
>>>>> altering
>>>>> entities<http://wiki.fluentnhibernate.org/show/AutoMappingAlteringEntities>
>>>>>  and
>>>>> mapping 
>>>>> overrides<http://wiki.fluentnhibernate.org/show/AutoMappingOverrides>.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Feb 11, 2009 at 8:43 PM, Ramana Kumar <
>>>>> ramana.r.ku...@gmail.com> wrote:
>>>>>
>>>>>> No, I did mean Many to One :-)  The Domain Objects are Golfer and
>>>>>> Address and many Golfers can share the same Address.  Per James
>>>>>> "i-think-you-mean-a-many-to-one-sir" G, this should be mapped as Many to
>>>>>> one. I am just not sure how to do it thru AutoMap conventions.
>>>>>> HTH
>>>>>> Ramana
>>>>>>
>>>>>>
>>>>>>  namespace GolfHandicapManager.Core
>>>>>> {
>>>>>> public class Golfer : Entity
>>>>>> {
>>>>>> public Golfer() { }
>>>>>> [DomainSignature]
>>>>>> [NotNullNotEmpty]
>>>>>> public virtual string FirstName { get; set; }
>>>>>> [DomainSignature]
>>>>>> [NotNullNotEmpty]
>>>>>> public virtual string LastName { get; set; }
>>>>>> [NotNullNot

[fluent-nhib] Re: Auto Mapper Enum Types

2009-02-18 Thread James Gregory
I can see your point, but I think you're overselling the problem. Creating a
really long enum name would fail with a truncation error the first time
anyone tried to save it to the db, I'm pretty sure even the worst developer
wouldn't miss that.
Using integers on the other hand suffers from the problem of inferred value,
where if you reorder the enum the values will change. Try debugging that
one. Sure you can explicitly set the values, but that's just more work.

This whole argument is moot if you use either the suggestion from Steven, or
follow a type-safe enum pattern. Both are much safer than a plain enum.


I've just looked at the CustomSqlTypeIs("string") thing and I have no idea
why that hasn't failed before. Removing it seems to correct that issue. As
for everything else, I don't know, I'll have to investigate more.

On Wed, Feb 18, 2009 at 5:02 PM, Mark Perry wrote:

>
> James
>
> Couple of things:
>
> EmumerationTypeConvention.cs line 19 "propertyMapping.CustomSqlTypeIs
> ("string");"
>
> AFAIK "string" is not a database type. I suspect you want to use the
> dialect
> thing here to write the correct type into the mapping.
>
> The "string" thing just broke when I tried to run it against my DB.
>
> Also although I now have:
>
> convention.AddTypeConvention(new MyEnumToIntConvention());
>
> in my auto mapping configuration my "AlterMap" method is never called
> for my enum types.
>
> I can see that the "FindConvetions" method in Conventions.cs line 80
> does return my custom convention but the AlterMap part is never
> called.
>
> Not 100% sure if this whole enum thing is supported in the auto mapper
> but thought I would being it up.
>
> Thanks, Mark
>
>
>
>
> On Feb 18, 4:14 pm, Mark Perry  wrote:
> > Thing is how big do you make your "string" column in your DB to cater
> > for all the lengths of the enums.
> >
> > The automapper is going to default to X but then some developer
> > comes along and adds "thisisareallylingenumvalue" and all of the
> > sudden
> > that's going break on the inside of the DB and make the enum cast as
> > the
> > default instead of the really long one. That is bad.
> >
> > If I use Ints in my DB not only am I safe from magic strings but I get
> > better indexing and reporting performance (yes I understand it's
> > marginal)
> > unfortunately that's how I grew up DB wise and my preferred solution.
> >
> > I realise that's more of a basic Nhibernate functionality question
> > rather than a FNH one, thanks for the swift response though.
> >
> > In your opinion am I better overloading ToString for my enum types to
> > return the Int value or creating an "AddTypeConvention" to handle it
> > there?
> >
> > Thanks, Mark
> >
> > On Feb 18, 1:33 pm, James Gregory  wrote:
> >
> > > CustomTypeIs is for specifying IUserTypes, so no that wouldn't work.
> > > Although perhaps I should remove that limitation and make CustomTypeIs
> just
> > > be for any type.
> >
> > > On Wed, Feb 18, 2009 at 1:27 PM, blindwillie 
> wrote:
> >
> > > > Shouldn't it be possible to do it like this:
> >
> > > > Map(x => x.MyEnum).CustomTypeIs(typeof(int));
> >
> > > > Because such line seems to be ignored right now. I don't know if
> > > > removing the "highlighted" line in the automapper will change that?
> >
> > > > /Asger
> >
> > > > On Feb 18, 2:23 pm, James Gregory  wrote:
> > > > > Well, that line you highlighted in AutoMapper doesn't make any
> sense.
> > > > > Removing it allows the automapper to map Enums; however, the
> recommended
> > > > > behavior in NHibernate is to map enums as strings, and that's what
> the
> > > > > automapper does.
> > > > > If you really must use enums as ints, then you'll need to manually
> set
> > > > the
> > > > > type attribute on the property. I've updated the enum convention to
> > > > ignore
> > > > > any enum properties that already have their type set.
> >
> > > > > Map(x => x.MyEnum)
> > > > >   .SetAttribute("type", "Int32");
> >
> > > > > On Wed, Feb 18, 2009 at 9:17 AM, Mark Perry <
> markperr...@googlemail.com
> > > > >wrote:
> >
> > > > > > James
> >
> > > > > > Have

[fluent-nhib] Re: How do I configure a session factory for oracle?

2009-02-19 Thread James Gregory
Good link Filip, I didn't know that existed. It's a shame people don't
submit things like that as patches.

On Thu, Feb 19, 2009 at 7:57 AM, Filip Kinsky  wrote:

>
> you can use configuration class for Oracle from this blog post:
>
> http://tiredblogger.wordpress.com/2008/12/04/persistanceconfiguration-for-oraclefluent-nhibernate/
>
> On 18 Ún, 22:32, George Mauer  wrote:
> > Almost certainly a stupid question but I can't find the answer
> > anywhere.
> >
> > In the Getting Started tutorial the database is SQLite and so his
> > session factory creation
> > is done using the SQLiteConfiguration class in the
> > FluentNHibernate.Cfg.Db namespace
> >
> > Great!  But I don't see a Configuration class for using an Oracle
> > database.  How do I do this?
> >
> > (sorry if this is a double post, I did not see it pop up and assume I
> > had clicked cancel by accident)
>
> >
>

--~--~-~--~~~---~--~~
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: how to create convention for sequence name for identity mapping (Oracle)?

2009-02-19 Thread James Gregory
Unfortunately there isn't support for this currently. There was an
issuecreated
for this a while back, but nobody's claimed it yet.

On Thu, Feb 19, 2009 at 7:55 AM, Filip Kinsky  wrote:

>
> Maybe I just can't see something obvious, but how can I create
> convention for mapping ID fields to Oracle's sequence with name like
> "seq_" + entityTypeName? I'm not able to figure out how to access the
> ID property type and according to source code (IdentityPart.cs) the
> _property member field is not published - should I send a patch for
> this or is there any other method how to build sequence name like
> this?
>
> model.Conventions.IdConvention = id => id.GeneratedBy.Sequence("seq_"
> + id.Property.DeclaringType.Name);
>
> >
>

--~--~-~--~~~---~--~~
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: Add multiple mappings

2009-02-19 Thread James Gregory
Hi Martin,
1. I'd not considered this usage, but it seems sensible. I'll make the
required changes so you can call Mappings multiple times.

2. This is difficult, because while the containers have the same purpose,
they don't have the same interface. Hbm and Fluent have some methods in
common (AddFromAssemblyOf) but the automappings one has no common
methods. It's hard to extract a common interface from these.

3. Sounds good from a SoC point of view, but you might struggle merging the
various sources. FNH has several steps it goes through before it actually
touches the NH Configuration (notably conventions and some conflict
avoidance when using multiple mapping types).

Personally, I'd go for the first approach once I fix the reuse issue.

On Thu, Feb 19, 2009 at 7:16 AM, Martin Nilsson  wrote:

> I'm looking into replacing Castle ActiveRecord with FNH. I have an
> application built with modules and each module provide it's configuration
> for AR so I can get the AR entities. I don't know how to do that in FNH. I
> have considered these approaches.
>
> 1. Let each module provide a MappingConfiguration and then use add them to
> Fluently.Configure but if I do
> .Mappings(configOne)
> .Mappings(configTwo)
> etc
> it seems that the mapping is overwritten each time due to a delegate
> member
>
> 2. Add mappings to MappingConfiguration but it has three different
> properties (Fluent, Auto and Hbm with no relation (common interface)) so I
> have to know how the module has configured it's mappings.
>
> 3. Hmmm.. Now when I have done some thinking (or something..) I shouldn't
> get anything FNH related but a NH Configuration or NH mappings. It might be
> hard to merge the configuration from different sources so one option could
> be to give access to the _real_ configuration to the modules and then let
> them add their stuff to the configuration. So this post maybe should go into
> nhusers list instead..
>
> Any ideas?
>
>
> >
>

--~--~-~--~~~---~--~~
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: Add multiple mappings

2009-02-19 Thread James Gregory
Actually, thinking about 1. some more, I think it depends on your design as
to whether any changes would be needed. Could you give me an example of how
you hoped to use it?
Mappings takes a lambda that gets applied to a MappingConfiguration
instance, you can use multiple lambdas and they'll all get applied to the
same instance. So if you had a class with a public method with a single
MappingConfiguration parameter, that could be used in place of the lambda,
making this quite easy to automate. Just thinking out loud. I'm curious to
hear why the current design wouldn't work for you.

On Thu, Feb 19, 2009 at 12:42 PM, James Gregory wrote:

> Hi Martin,
> 1. I'd not considered this usage, but it seems sensible. I'll make the
> required changes so you can call Mappings multiple times.
>
> 2. This is difficult, because while the containers have the same purpose,
> they don't have the same interface. Hbm and Fluent have some methods in
> common (AddFromAssemblyOf) but the automappings one has no common
> methods. It's hard to extract a common interface from these.
>
> 3. Sounds good from a SoC point of view, but you might struggle merging the
> various sources. FNH has several steps it goes through before it actually
> touches the NH Configuration (notably conventions and some conflict
> avoidance when using multiple mapping types).
>
> Personally, I'd go for the first approach once I fix the reuse issue.
>
>
> On Thu, Feb 19, 2009 at 7:16 AM, Martin Nilsson wrote:
>
>> I'm looking into replacing Castle ActiveRecord with FNH. I have an
>> application built with modules and each module provide it's configuration
>> for AR so I can get the AR entities. I don't know how to do that in FNH. I
>> have considered these approaches.
>>
>> 1. Let each module provide a MappingConfiguration and then use add them to
>> Fluently.Configure but if I do
>> .Mappings(configOne)
>> .Mappings(configTwo)
>> etc
>> it seems that the mapping is overwritten each time due to a delegate
>> member
>>
>> 2. Add mappings to MappingConfiguration but it has three different
>> properties (Fluent, Auto and Hbm with no relation (common interface)) so I
>> have to know how the module has configured it's mappings.
>>
>> 3. Hmmm.. Now when I have done some thinking (or something..) I shouldn't
>> get anything FNH related but a NH Configuration or NH mappings. It might be
>> hard to merge the configuration from different sources so one option could
>> be to give access to the _real_ configuration to the modules and then let
>> them add their stuff to the configuration. So this post maybe should go into
>> nhusers list instead..
>>
>> Any ideas?
>>
>>
>> >>
>>
>

--~--~-~--~~~---~--~~
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: Constraints not making it to the database schema

2009-02-19 Thread James Gregory
There was a bug in the Not.Nullable code that I've just fixed, could you
confirm (or deny) whether this has had any affect on your problem?

On Thu, Feb 19, 2009 at 12:09 AM, Steven Lyons wrote:

>
> Hi All,
>
> I'm having a weird problem that hopefully someone might have some
> thoughts about.
>
> I am trying to auto map and assign more specific constraints to a type
> (see User in code below). This is mostly just basic code I've gotten
> from blogs. When I run my test, the hbm export file is created and has
> the correct attributes. However, the the SchemaExport output to the
> console is missing the unique constraint and non-null specification.
>
> The strange part is that is if I use the hbm mappings in the
> BuildSessionFactory method (currently commented out) the constraints
> are added to the schema. It's when I try to use the auto mapping that
> I run into trouble. I also had this working previously (using the non-
> fluent configuration, see below) but that code also stopped working
> with the same problem when I updated to a recent FNH version.
>
> Is this something that I was doing wrong before and just happened to
> work? Or is this a regression?
>
> Thanks!
> s.
>
>
> ---
>
> // Create SessionFactory
> UnitOfWork.SessionFactory = new NHibernateHelper().BuildSessionFactory
> (config, BuildSchema);
>
> // Export Schema
> public void BuildSchema(Configuration cfg)
> {
>new SchemaExport(cfg).Create(true, true);
> }
>
> // Build Session Factory
> public ISessionFactory BuildSessionFactory(Configuration config,
>   Action
> configAction)
> {
>var f = FluentNHibernate.Cfg.Fluently
>.Configure(config)
>.Mappings(m =>
>{
>//m.HbmMappings
>// .AddFromAssemblyOf();
>
>m.AutoMappings.Add(
>AutoPersistenceModel.MapEntitiesFromAssemblyOf
> ()
>.Where(entity => entity.Namespace.Contains
> ("Domain") &&
> entity.GetProperty("Id") != null
> &&
> entity.IsAbstract == false)
>.WithConvention(convention =>
>{
>convention.IsBaseType = (type => (type ==
> typeof(Entity) ||
> (type ==
> typeof(Entity;
>})
>.ForTypesThatDeriveFrom(map =>
>{
>map.Map(p => p.Username).Unique().Not.Nullable
> ();
>})
>).ExportTo(@"c:\src\project\log\");
>})
>.ExposeConfiguration(configAction)
>.BuildSessionFactory();
>
>return f;
> }
>
> 
> 
>  lazy="true" assembly="Project.Core" namespace="Project.Core.Domain">
>  
>  
>
>  
> length="100" type="String">
>  
>
>  
> 
>
> -- SQLite schema export:
> create table Users (
>  Id UNIQUEIDENTIFIER not null,
>   Username TEXT,
>   primary key (Id)
> )
>
> // Previously working code
> public PersistenceModel BuildModel()
> {
>var model = new AutoPersistenceModel();
>
>foreach (Assembly assembly in this.fluentAssemblies)
>{
>// Add assembly for the fluent mapping files
>model.addMappingsFromAssembly(assembly);
>
>// Add assembly and configuration for fluent AutoMapped
> classes
>model.AddEntityAssembly(assembly);
>}
>
>model.Where(entity => entity.Namespace.Contains("Domain") &&
>  entity.GetProperty("Id") != null &&
>  entity.IsAbstract == false)
> .WithConvention(c =>
>  {
>  c.IsBaseType = (type => (type == typeof(Entity) ||
>  (type == typeof
> (Entity;
> });
>
>// TODO: Move these out to a proper location!!!
>model.ForTypesThatDeriveFrom(map =>
>{
>map.Map(p => p.Username).WithUniqueConstraint()
>   .CanNotBeNull();
>});
>
>return model;
> }
> >
>

--~--~-~--~~~---~--~~
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: How do I configure a session factory for oracle?

2009-02-19 Thread James Gregory
That's interesting. The code does look out of date actually.
Shouldn't be too difficult to derive from the PersistenceConfiguration class
and create your own OracleConfiguration. I'd do it myself but I don't have
oracle or really know the different options available in it's connection
string.

On Thu, Feb 19, 2009 at 2:40 PM, George Mauer  wrote:

>
> For the record, I tried that class but couldn't get it working.  It
> has a dependency on a class that no longer exists in fluent-nhibernate
> and even after fixing that I kept getting an error that FNH was
> looking for classes that didn't exist in my Oracle.DataAccess class
>
> On Feb 19, 6:05 am, James Gregory  wrote:
> > Good link Filip, I didn't know that existed. It's a shame people don't
> > submit things like that as patches.
> >
> > On Thu, Feb 19, 2009 at 7:57 AM, Filip Kinsky  wrote:
> >
> > > you can use configuration class for Oracle from this blog post:
> >
> > >http://tiredblogger.wordpress.com/2008/12/04/persistanceconfiguration.
> ..
> >
> > > On 18 Ún, 22:32, George Mauer  wrote:
> > > > Almost certainly a stupid question but I can't find the answer
> > > > anywhere.
> >
> > > > In the Getting Started tutorial the database is SQLite and so his
> > > > session factory creation
> > > > is done using the SQLiteConfiguration class in the
> > > > FluentNHibernate.Cfg.Db namespace
> >
> > > > Great!  But I don't see a Configuration class for using an Oracle
> > > > database.  How do I do this?
> >
> > > > (sorry if this is a double post, I did not see it pop up and assume I
> > > > had clicked cancel by accident)
> >
>

--~--~-~--~~~---~--~~
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: Mapping enums to INT values - not strings

2009-02-19 Thread James Gregory
When was the last time you did an update? There was a bug relating to this
that I fixed about an hour ago.

On Thu, Feb 19, 2009 at 2:54 PM, Tom Warnat  wrote:

>  This does not seem to work with MySQL.
>
> The SQL Query is something like this:
>
> Create table foo (
>
> FooID INTEGER NOT NULL AUTO_INCREMENT,
>
> EnumProperty string,
>
> primary key (FooID)
>
> );
>
>
>
> I used Map(x => x.EnumProperty).CustomTypeIs(typeof(int)); with the
> PersistenceModel on MySQL 5.0.74
>
>
>
> Derick Bailey
> Tue, 16 Dec 2008 09:32:29 -0800
>
> @Craig,
>
> > This seemed to work for me, but anyone speak up if this is wrong:
>
> >
>
> > Map(x => x.SomeEnumProperty ).CustomTypeIs(typeof(int));
>
> >
>
> > -Craig
>
>
>
>
>
> D'OH! It would be something that simple. :) thanks Craig!
>
>
>
>
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Newbie message

2009-02-19 Thread James Gregory
Hello Gabriele,


> My concern about Fluent NHibernate is that I don't know which level
> of support it's being given by the NHibernate developing community, and even
> if I like very much the idea behind it, I don't know if I feel

safe including such a tool in a mission-critical project.


What kind of support do you mean? There is no commercial support available,
although I'm sure an arrangement could be made if there was the need. As for
regular support (bug fixes and QAs) check the mailing list history - I'm
here most hours of the day, every day, answering questions and committing
changes.

For this reason, even if the code is not very commented (that's also a defect
> of mine), still it's very expressive and readily understandable.


Thank you, but please be aware the only deficiency in our commenting is only
our lack of public API xml-docs. Regular code comments are
deliberatelysparse, as they should be.

Here I think I've found a small bug/nonDesirableFeature. Could anybody tell
> me where I can signal it and maybe contribute with a small patch?
>

The typical thing is that you (or anyone else who finds a bug) will mention
it on the mailing list, and get verification from one of us that it's
definitely a bug, and then create a new issue on our issues
list;
issues with patches attached are very much appreciated.

I would also appreciate anybody's sharing his/her thoughts about Fluent with
> a newbie like me!


Any questions or comments are always welcome here on the mailing list.
Myself and the other contributors will try to answer any questions
promptly.

James

On Thu, Feb 19, 2009 at 4:25 PM, Gabriele Tassi wrote:

>
> Hello Everybody,
>
> I've just discovered this new tool and I find it great!
> I would like to use it to refactor an existing project of which I'm
> not completely happy.
> This project has been made with AndroMDA, a tool that left me quite
> disappointed.
>
> /*
> By the way, my two cents about MDA in general: everybody's striving to
> bridge the gap between object model and relational model, and maybe
> its not a great idea to bring directly inside the heart of development
> still another model, that is UML. Too rough a judgement? maybe, but
> that's not the place for being smart...
> */
>
> My concern about Fluent NHibernate is that I don't know which level of
> support it's being given by the NHibernate developing community, and
> even if I like very much the idea behind it, I don't know if I feel
> safe including such a tool in a mission-critical project.
>
> Having said that, I like the source code of Fluent NHibernate very
> much: and if one thinks about it, that's hardly surprising, since from
> a project whose aim is, among others, to make NHibernate programming
> look more beautiful, it's logical to expect beautiful source code.
>
> For this reason, even if the code is not very commented (that's also a
> defect of mine), still it's very expressive and readily
> understandable. So my best compliments to the contributors!
>
> While I decide whether to include this tool in my beloved project, I'm
> playing a bit with it and I'm examining the source code. Here I think
> I've found a small bug/nonDesirableFeature.
>
> Could anybody tell me where I can signal it and maybe contribute with
> a small patch?
>
> I would also appreciate anybody's sharing his/her thoughts about
> Fluent with a newbie like me!
> Bye everybody and enjoy!
>
> >
>

--~--~-~--~~~---~--~~
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: Newbie message

2009-02-19 Thread James Gregory
>
> I just meant to say that it would be great if this tool became part of
> NHibernate itself, maybe in the Contrib project.


Could you explain why you think this would be a good thing? I'm interested
because I actually made the opposite decision recently, and would like to
hear opinions for the other side. What difference would there be if we were
a part of Contrib?

On Thu, Feb 19, 2009 at 6:00 PM, Gabriele Tassi wrote:

>
> Hi James,
>
> thanks for the prompt and detailed answer.
> I will do as you told me about that small bug (if indeed it's one...).
> For what may has seemed a complaint about support, I just meant to say
> that it would be great if this tool became part of NHibernate itself,
> maybe in the Contrib project.
> But since this has to do with project management issues that are
> definitely none of my business, please forget what I've said ;-)
>
> I really wish you the best from this beautiful project!
> Gabriele.
>
> >
>

--~--~-~--~~~---~--~~
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: Fwd: FNH patch

2009-02-19 Thread James Gregory
Thanks Jimit, I will review and apply these as soon as I get the
opportunity. Time is short right now.

On Thu, Feb 19, 2009 at 6:03 PM, Jimit Ndiaye  wrote:

>
>
> Sent from my iPhone
>
> Begin forwarded message:
>
> The attached patch contains the following:
>
> 1) Added support for mapping entities from multiple assemblies
>
> 2) Fixed issue with mapping nested classes
>
> 3) Fixed issue with duplicate mapping being generated for subclasses when
> overridden in a mapping override (IAutoMappingOverride).
>
> These issues are raised in the following threads:
>
> 
> http://groups.google.com/group/fluent-nhibernate/t/73d814a601af4919
>  
> http://groups.google.com/group/fluent-nhibernate/t/15fdb057ec89078e
>
> *(See attached file: Cumulative Patch.patch)*
>
>
>
>

--~--~-~--~~~---~--~~
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: Constraints not making it to the database schema

2009-02-19 Thread James Gregory
Thanks for the heads up, I'll fix this asap.

On Thu, Feb 19, 2009 at 10:27 PM, Steven Lyons wrote:

>
> It looks like same problem occurs with the length attribute. As with
> the previous fix, when the column element is present in a property, as
> it is the FNH hbm exports, the length should be on the column instead
> of the property.
>
>
> On Feb 19, 11:23 am, Steven Lyons  wrote:
> > Hi James,
> >
> > The new fix has partly resolved the issue. The "not null" is now
> > making it through to the schema but the unique constraint is still
> > being dropped.
> >
> > s.
> >
> > On Feb 19, 9:35 am, James Gregory  wrote:
> >
> > > There was a bug in the Not.Nullable code that I've just fixed, could
> you
> > > confirm (or deny) whether this has had any affect on your problem?
> >
> > > On Thu, Feb 19, 2009 at 12:09 AM, Steven Lyons  >wrote:
> >
> > > > Hi All,
> >
> > > > I'm having a weird problem that hopefully someone might have some
> > > > thoughts about.
> >
> > > > I am trying to auto map and assign more specific constraints to a
> type
> > > > (see User in code below). This is mostly just basic code I've gotten
> > > > from blogs. When I run my test, the hbm export file is created and
> has
> > > > the correct attributes. However, the the SchemaExport output to the
> > > > console is missing the unique constraint and non-null specification.
> >
> > > > The strange part is that is if I use the hbm mappings in the
> > > > BuildSessionFactory method (currently commented out) the constraints
> > > > are added to the schema. It's when I try to use the auto mapping that
> > > > I run into trouble. I also had this working previously (using the
> non-
> > > > fluent configuration, see below) but that code also stopped working
> > > > with the same problem when I updated to a recent FNH version.
> >
> > > > Is this something that I was doing wrong before and just happened to
> > > > work? Or is this a regression?
> >
> > > > Thanks!
> > > > s.
> >
> > > > ---
> >
> > > > // Create SessionFactory
> > > > UnitOfWork.SessionFactory = new
> NHibernateHelper().BuildSessionFactory
> > > > (config, BuildSchema);
> >
> > > > // Export Schema
> > > > public void BuildSchema(Configuration cfg)
> > > > {
> > > >new SchemaExport(cfg).Create(true, true);
> > > > }
> >
> > > > // Build Session Factory
> > > > public ISessionFactory BuildSessionFactory(Configuration config,
> > > >   Action
> > > > configAction)
> > > > {
> > > >var f = FluentNHibernate.Cfg.Fluently
> > > >.Configure(config)
> > > >.Mappings(m =>
> > > >{
> > > >//m.HbmMappings
> > > >// .AddFromAssemblyOf();
> >
> > > >m.AutoMappings.Add(
> > > >
>  AutoPersistenceModel.MapEntitiesFromAssemblyOf
> > > > ()
> > > >.Where(entity => entity.Namespace.Contains
> > > > ("Domain") &&
> > > > entity.GetProperty("Id") != null
> > > > &&
> > > > entity.IsAbstract == false)
> > > >.WithConvention(convention =>
> > > >{
> > > >convention.IsBaseType = (type => (type ==
> > > > typeof(Entity) ||
> > > > (type ==
> > > > typeof(Entity;
> > > >})
> > > >.ForTypesThatDeriveFrom(map =>
> > > >{
> > > >map.Map(p => p.Username).Unique().Not.Nullable
> > > > ();
> > > >})
> > > >).ExportTo(@"c:\src\project\log\");
> > > >})
> > > >.ExposeConfiguration(configAction)
> > > >.BuildSessionFactory();
> >
> > > >return f;
> > > > }
> >
> > > > 
> > > > 
> > > >  > > > lazy="true" assembly="Pro

[fluent-nhib] Re: Now Where should I start

2009-02-20 Thread James Gregory
Paul, Andy: I've been working on a rather large rewrite of conventions for
trunk, so I've got that one covered. I currently have all the changes in a
local git branch, but I'll try to get it pushed to a public svn one so you
guys can take a look (if you're interested).
Paul, obviously we don't have visitors in trunk so my approach is a little
different than we would probably have done if it was only for the semantic
model; however, I think most of it can be ported to the new code-base quite
easily. I don't really think visitors are suited to being the public
interface to conventions anyway, they're a little too verbose for simple
usage - however, that doesn't mean they can't be the backing to the public
API (by all means, they should be the backing!).

Basically my changes are a result of trying to work on the semantic model
stuff, but every 5 minutes there's a new "I can't do this with such-and-such
convention", so my redesign is one that's highly specialised, but can also
be highly generic - so it should tide people over while we focus on the SM.

The new conventions are represented by a set interfaces of gradually
increasing granularity (IClassConvention, IMappingPartConvention,
IRelationshipConvention, IHasManyConvention etc...). Classes that implement
these convention interfaces are discovered by FNH automagically and applied
after the normal mapping has occurred. This has two side-effects, firstly
there's now no mention of conventions in any of the mapping classes (none of
this conventions.AlterId malarky), and secondly if there isn't a convention
already made for a specific purpose (say ManyToManyJoinTableName) then the
user can simply use the interface with a reduced granularity (say
IClassConvention) to implement the desired behaviour in the same way we
would but in their own code-base.

Where the visitors fit into this is replacing the discovery code, which is
currently the only thing invoked manually in the code-base. It would be
quite well suited to loading this into a visitor instead.

Hopefully all this should drop in trunk over the next few days, then I can
focus on merging/converting it to work with the new design.

That was a bit longer than I expected :)

On Fri, Feb 20, 2009 at 9:10 AM, Andrew Stewart wrote:

> Good Morning Paul.
> I'll perform a check out of the rewrite branch this morning, and start to
> investigate automapping somepoint today. I agree with you on
> the Convention class in the trunk, as soon as I saw it I could see it would
> need refactoring at somepoint.
>
> I'll be in touch when I get something working.
>
> Cheers
>
> Andy
>
>
>>
>> On Fri, Feb 20, 2009 at 6:22 AM, Paul Batum  wrote:
>>
>>> Gday Andy,
>>>
>>> Progress on the semantic model has slowed these last few weeks as I've
>>> returned to the land of the employed, but basically, I can't see any reason
>>> why you couldn't start work on an automapper that works against the semantic
>>> model. The model is missing alot of features so there is no way that people
>>> could realistically switch over yet, but there is enough there to get some
>>> basic automapping working.
>>>
>>> If you decide to start, I would suggest that you create a AutoMapping
>>> folder in the FluentNHibernate.FluentInterface project and put your
>>> implementation there. If you take a look in the test project, you'll see
>>> there are some integration tests that map some really small domains (music
>>> and employees I think) - I think a good inital goal would be to get those
>>> domains automapped.
>>>
>>> There will probably be lots of friction as you discover that certain
>>> things are missing or done differently in the rewrite, but we'll just have
>>> to work through that. A good example would be that the Conventions class no
>>> longer exists, and will hopefully stay that way. Conventions should instead
>>> be implemented as visitors of the mapping model - see NamingConvention as an
>>> example. I have a blog post that sort of covers this in the works  - I'm
>>> really going to try to get that finished this weekend. In any case, feel
>>> free to ping me with whatever questions you have.
>>>
>>> Paul Batum
>>>
>>>
>>> On Fri, Feb 20, 2009 at 7:04 AM, Andrew Stewart <
>>> andrewnstew...@gmail.com> wrote:
>>>
 Hi
 I'm getting towards the end of one of my personal projects, so I'm going
 to be in a position to start contributing again. Where am I best
 concentrating my effort at the moment, on the PB rewrite branch of
 supporting the main trunk?

 Cheers

 Andy

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

 Easy Project Managment Online
 http://www.task-mate.com





>>>
>>>
>>>
>>
>>
>> --
>> =
>> I-nnovate Software - Bespoke Software Development, uk wirral.
>> http://www.i-nnovate.net
>>
>> Easy Project Managment Online
>> http://www.task-mate.com
>>
>>
>>
>
>
> --
> ==

[fluent-nhib] Re: Newbie message

2009-02-20 Thread James Gregory
My decision was very much driven from a project management point of view, so
it's been interesting to hear your perspective as a user; I will bare your
comments in mind next time I come to consider Fluent NHibernate's place in
the big scheme of things.
I've just paid for a year's website hosting though, so we won't be going
anywhere for a while :)
On Fri, Feb 20, 2009 at 3:35 PM, Gabriele Tassi wrote:

>
> Well, I just have the feeling that projects grouped in Contrib can get
> a greater visibility.
> I mean, you are looking for a Linq to NHibernate mapper and you
> stumble upon Fluent and you say "Oh, that's great! I wouldn't ever
> have thought about it! let me give it a try...".
> And knowing that the developer community is larger (even if the number
> of guys working on each individual contrib doesn't change of course),
> could give a greater feeling of confidence.
> As I said, it's more a matter of the feeling that potential users can
> have about it, it has nothing to do with the quality of the project
> and the real nework of users and developers.
>
> But now you could suspect I'm a NHibernate Contrib secret agent! :)
>
> >
>

--~--~-~--~~~---~--~~
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: Now Where should I start

2009-02-20 Thread James Gregory
The whole merge into svn is taking too long for a friday night, so I'll do
it tomorrow. You get the general idea though, i'm sure.

On Fri, Feb 20, 2009 at 7:03 PM, James Gregory wrote:

> Paul, Andy: I've been working on a rather large rewrite of conventions for
> trunk, so I've got that one covered. I currently have all the changes in a
> local git branch, but I'll try to get it pushed to a public svn one so you
> guys can take a look (if you're interested).
> Paul, obviously we don't have visitors in trunk so my approach is a little
> different than we would probably have done if it was only for the semantic
> model; however, I think most of it can be ported to the new code-base quite
> easily. I don't really think visitors are suited to being the public
> interface to conventions anyway, they're a little too verbose for simple
> usage - however, that doesn't mean they can't be the backing to the public
> API (by all means, they should be the backing!).
>
> Basically my changes are a result of trying to work on the semantic model
> stuff, but every 5 minutes there's a new "I can't do this with such-and-such
> convention", so my redesign is one that's highly specialised, but can also
> be highly generic - so it should tide people over while we focus on the SM.
>
> The new conventions are represented by a set interfaces of gradually
> increasing granularity (IClassConvention, IMappingPartConvention,
> IRelationshipConvention, IHasManyConvention etc...). Classes that implement
> these convention interfaces are discovered by FNH automagically and applied
> after the normal mapping has occurred. This has two side-effects, firstly
> there's now no mention of conventions in any of the mapping classes (none of
> this conventions.AlterId malarky), and secondly if there isn't a convention
> already made for a specific purpose (say ManyToManyJoinTableName) then the
> user can simply use the interface with a reduced granularity (say
> IClassConvention) to implement the desired behaviour in the same way we
> would but in their own code-base.
>
> Where the visitors fit into this is replacing the discovery code, which is
> currently the only thing invoked manually in the code-base. It would be
> quite well suited to loading this into a visitor instead.
>
> Hopefully all this should drop in trunk over the next few days, then I can
> focus on merging/converting it to work with the new design.
>
> That was a bit longer than I expected :)
>
> On Fri, Feb 20, 2009 at 9:10 AM, Andrew Stewart 
> wrote:
>
>> Good Morning Paul.
>> I'll perform a check out of the rewrite branch this morning, and start to
>> investigate automapping somepoint today. I agree with you on
>> the Convention class in the trunk, as soon as I saw it I could see it would
>> need refactoring at somepoint.
>>
>> I'll be in touch when I get something working.
>>
>> Cheers
>>
>> Andy
>>
>>
>>>
>>> On Fri, Feb 20, 2009 at 6:22 AM, Paul Batum wrote:
>>>
>>>> Gday Andy,
>>>>
>>>> Progress on the semantic model has slowed these last few weeks as I've
>>>> returned to the land of the employed, but basically, I can't see any reason
>>>> why you couldn't start work on an automapper that works against the 
>>>> semantic
>>>> model. The model is missing alot of features so there is no way that people
>>>> could realistically switch over yet, but there is enough there to get some
>>>> basic automapping working.
>>>>
>>>> If you decide to start, I would suggest that you create a AutoMapping
>>>> folder in the FluentNHibernate.FluentInterface project and put your
>>>> implementation there. If you take a look in the test project, you'll see
>>>> there are some integration tests that map some really small domains (music
>>>> and employees I think) - I think a good inital goal would be to get those
>>>> domains automapped.
>>>>
>>>> There will probably be lots of friction as you discover that certain
>>>> things are missing or done differently in the rewrite, but we'll just have
>>>> to work through that. A good example would be that the Conventions class no
>>>> longer exists, and will hopefully stay that way. Conventions should instead
>>>> be implemented as visitors of the mapping model - see NamingConvention as 
>>>> an
>>>> example. I have a blog post that sort of covers this in the works  - I'm
>>>> really going to t

[fluent-nhib] Re: Now Where should I start

2009-02-20 Thread James Gregory
Conventions svn
branch<http://code.google.com/p/fluent-nhibernate/source/browse/#svn/branches/conventions>,
most stuff is in src/FluentNHibernate/Conventions

On Fri, Feb 20, 2009 at 7:29 PM, James Gregory wrote:

> The whole merge into svn is taking too long for a friday night, so I'll do
> it tomorrow. You get the general idea though, i'm sure.
>
>
> On Fri, Feb 20, 2009 at 7:03 PM, James Gregory wrote:
>
>> Paul, Andy: I've been working on a rather large rewrite of conventions
>> for trunk, so I've got that one covered. I currently have all the changes in
>> a local git branch, but I'll try to get it pushed to a public svn one so you
>> guys can take a look (if you're interested).
>> Paul, obviously we don't have visitors in trunk so my approach is a little
>> different than we would probably have done if it was only for the semantic
>> model; however, I think most of it can be ported to the new code-base quite
>> easily. I don't really think visitors are suited to being the public
>> interface to conventions anyway, they're a little too verbose for simple
>> usage - however, that doesn't mean they can't be the backing to the public
>> API (by all means, they should be the backing!).
>>
>> Basically my changes are a result of trying to work on the semantic model
>> stuff, but every 5 minutes there's a new "I can't do this with such-and-such
>> convention", so my redesign is one that's highly specialised, but can also
>> be highly generic - so it should tide people over while we focus on the SM.
>>
>> The new conventions are represented by a set interfaces of gradually
>> increasing granularity (IClassConvention, IMappingPartConvention,
>> IRelationshipConvention, IHasManyConvention etc...). Classes that implement
>> these convention interfaces are discovered by FNH automagically and applied
>> after the normal mapping has occurred. This has two side-effects, firstly
>> there's now no mention of conventions in any of the mapping classes (none of
>> this conventions.AlterId malarky), and secondly if there isn't a convention
>> already made for a specific purpose (say ManyToManyJoinTableName) then the
>> user can simply use the interface with a reduced granularity (say
>> IClassConvention) to implement the desired behaviour in the same way we
>> would but in their own code-base.
>>
>> Where the visitors fit into this is replacing the discovery code, which is
>> currently the only thing invoked manually in the code-base. It would be
>> quite well suited to loading this into a visitor instead.
>>
>> Hopefully all this should drop in trunk over the next few days, then I can
>> focus on merging/converting it to work with the new design.
>>
>> That was a bit longer than I expected :)
>>
>> On Fri, Feb 20, 2009 at 9:10 AM, Andrew Stewart > > wrote:
>>
>>> Good Morning Paul.
>>> I'll perform a check out of the rewrite branch this morning, and start to
>>> investigate automapping somepoint today. I agree with you on
>>> the Convention class in the trunk, as soon as I saw it I could see it would
>>> need refactoring at somepoint.
>>>
>>> I'll be in touch when I get something working.
>>>
>>> Cheers
>>>
>>> Andy
>>>
>>>
>>>>
>>>> On Fri, Feb 20, 2009 at 6:22 AM, Paul Batum wrote:
>>>>
>>>>> Gday Andy,
>>>>>
>>>>> Progress on the semantic model has slowed these last few weeks as I've
>>>>> returned to the land of the employed, but basically, I can't see any 
>>>>> reason
>>>>> why you couldn't start work on an automapper that works against the 
>>>>> semantic
>>>>> model. The model is missing alot of features so there is no way that 
>>>>> people
>>>>> could realistically switch over yet, but there is enough there to get some
>>>>> basic automapping working.
>>>>>
>>>>> If you decide to start, I would suggest that you create a AutoMapping
>>>>> folder in the FluentNHibernate.FluentInterface project and put your
>>>>> implementation there. If you take a look in the test project, you'll see
>>>>> there are some integration tests that map some really small domains (music
>>>>> and employees I think) - I think a good inital goal would be to get those
>>>>> domains automapped.
>>>>>
>>>>> Ther

[fluent-nhib] Re: Some blog posts on my semantic model work

2009-02-21 Thread James Gregory
Good read Paul, shows some very nice work.

On Sat, Feb 21, 2009 at 6:16 AM, Paul Batum  wrote:

> Today I published my second post in a series that attempts to explain
> different aspects of my rewrite of Fluent NHibernate to use a semantic
> model.
>
> Today's post is about visitors:
> http://www.paulbatum.com/2009/02/fluent-nhibernate-semantic-model_21.html
>
> The previous post was about my unusual method of managing attributes:
> http://www.paulbatum.com/2009/02/fluent-nhibernate-semantic-model.html
>
> I would love to get some feedback on these. Thanks!
>
> Paul Batum
>
> >
>

--~--~-~--~~~---~--~~
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: Enums not mapping properly

2009-02-23 Thread James Gregory
Try now.

On Mon, Feb 23, 2009 at 5:04 AM, Karron Qiu  wrote:

>
> It worked before.  But the trunk version throws an exception:
>
> NHibernate.HibernateException: Column, parameter, or variable #2:
> Cannot find data type string.
>
> --
> Regards,
> Karron
>
> >
>

--~--~-~--~~~---~--~~
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: Problem with Property.WithLengthOf

2009-02-23 Thread James Gregory
This is fixed now, as of 2 minutes ago. Stupid bug.

On Mon, Feb 23, 2009 at 6:59 PM, Steven Lyons  wrote:

>
> I can't attach files to the messages on this forum, so it's just
> inline in the last message of the thread. You can just copy the text
> into a .patch file and apply it to your working copy.
>
>
> On Feb 23, 1:33 pm, Martin Nilsson  wrote:
> > Thanks!
> > But I couldn't find the patch to apply for this fix.
> >
> > On Mon, Feb 23, 2009 at 7:10 PM, Steven Lyons 
> wrote:
> >
> > > Martin,
> >
> > > This is a problem that is known. If you want to fix it in your source
> > > until it gets fixed, you can find a patch I made in this message:
> >
> > >http://groups.google.com/group/fluent-nhibernate/browse_thread/thread.
> ..
> >
> > > Hope it works for you,
> > > s.
> >
> > > On Feb 22, 3:03 pm, Martin Nilsson  wrote:
> > > > More info in this thread because I thought it was a problem in
> NHhttp://
> > > groups.google.com/group/nhusers/browse_thread/thread/81e8cffa5...
> >
> > > > Class:
> > > > public class Entity
> > > > {
> > > >   public virtual Guid Id { get; set; }
> > > >   public virtual string Content { get; set; }
> >
> > > > }
> >
> > > > Mapping:
> > > > public EntityMap()
> > > > {
> > > >   Id(x => x.Id);
> > > >   Map(x => x.Content).WithLengthOf(2500);
> >
> > > > }
> >
> > > > Generates this part in the hbm:
> > > > 
> > > >   
> > > > 
> >
> > > > And when I run SchemaExport.Create it looks at *column *and it has no
> > > length
> > > > defined so length of column in table != 2500
> >
> > > > You can also check this test in Fluent
> >
> > >
> PropertyMapTester.Map_WithFluentLength_OnString_UsesWithLengthOf_PropertyColumnAttribute:
> > > > ClassElement.innerXml == " > > > type=\"String\">"
> >
>

--~--~-~--~~~---~--~~
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: How to save relations

2009-02-24 Thread James Gregory
Have a look at Cascade, that'll make NH do the saving for you.

On Tue, Feb 24, 2009 at 9:26 AM, Tom Warnat  wrote:

>  I apologize for the inconvenience.
>
>
>
> I get it now.
>
>
>
> foreach(var element in childs)
>
> {
>
> session.Save(element);
>
> }
>
>
>
> *From:* fluent-nhibernate@googlegroups.com [mailto:
> fluent-nhibern...@googlegroups.com] *On Behalf Of *Tom Warnat
> *Sent:* Montag, 23. Februar 2009 15:18
> *To:* fluent-nhibernate@googlegroups.com
> *Subject:* [fluent-nhib] How to save relations
>
>
>
> Hi there again,
>
>
>
> i’m trying so save an HasManyMapping but getting an Exception while saving:
>
>
>
> {"Unknown entity class:
> NHibernate.Collection.Generic.PersistentGenericBag`1[[Mauve.LibriInterface.Core.BusinessObjects.ProductWebSite,
> Mauve.LibriInterface.Core, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=null]]"}
>
>
>
> Code is something like this:
>
>
>
> class Parent
>
> {
>
> public virtual int Id {get;set;}
>
> public virtual string Name {get;set;}
>
> public virtual IList Childs {get;set;}
>
>
>
> public Parent()
>
> {
>
> this.Name = String.Empty;
>
> this.Childs = new List();
>
> }
>
> }
>
>
>
> class Child
>
> {
>
> public virtual int Id {get;set;}
>
> public virtual string Something {get;set;}
>
>
>
> public Child()
>
> {
>
> this.Something = String.Empty;
>
> }
>
> }
>
>
>
> Mappings are:
>
>
>
> class ParentMap : ClassMap
>
> {
>
> public ParentMap()
>
> {
>
> Id(x=>x.Id);
>
> Map(x=>x.Name);
>
> HasMany(x=>x.Childs);
>
> }
>
> }
>
>
>
> class ChildMap : ClassMap
>
> {
>
> public ChildMap()
>
> {
>
> Id(x=>x.Id);
>
> Map(x=>x.Something);
>
> }
>
> }
>
>
>
> I use the PersistenceModel with fluent Configuration.
>
>
>
> Saving Method looks like this:
>
>
>
> try
>
> {
>
> List parents = GetParents();
>
>
>
> using (var transaction = session.BeginTransaction())
>
> {
>
> try
>
> {
>
> foreach (var parent in parents)
>
> {
>
> session.Save(parent);
>
>
>
>
> session.Save(product.Child);
>
> }
>
>
>
> transaction.Commit();
>
> }
>
> catch (Exception)
>
> {
>
> transaction.Rollback();
>
>
>
> throw;
>
> }
>
> }
>
> }
>
> finally
>
> {
>
> session.Flush();
>
> session.Clear();
>
> session.Close();
>
> session.Dispose();
>
> }
>
> }
>
>
>
> I have to save the child because flushing does not seem to work, but should
> regarding to some blog. Any thoughts on this? Thanks in advance.
>
>
>
>
>
>
>
> >
>

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



<    1   2   3   4   5   6   7   8   9   10   >