[nhusers] Re: Using Hi/Lo Generator
system wide uniqueness is much better. and as for the people asking about what the behaviour was - the simplest thing is to setup a quick two-entity domain with hilo id, new one instance of each, session.Save them both and peek into the generated data. On Thu, Mar 26, 2009 at 1:09 AM, Fabio Maulo fabioma...@gmail.com wrote: 2009/3/25 Tuna Toksoz tehl...@gmail.com A per table id stuff may be useful. I am going to add it to jira, but not sure if there is a need :) Please avoid it because it is supported by mapping. -- Fabio Maulo -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
Haven't read the whole message (i will in a moment) but a quick answer would be did you try NH Search, or pure lucene indexing? Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Mar 26, 2009 at 10:30 AM, Peter Morris mrpmor...@gmail.com wrote: Fabio gives the answer but do you really need to do it? Not sure :-) I have a Song class which has a Name property. When the user searches for a song I want to list songs with a similar name to what they entered rather than the exact string. To achieve this I am considering doing something like 1: Remove all characters so I only have consonants (except for first letters of words) 2: Remove all adjacent repeating letters 3: Convert to lower case 4: For each remaining word calculate a 32bit hash code For Song I will then have an association Song 1 *WordHash So My bonny lies over the occean would become my = 4622 bny = 6732 ls = 3623 ovr = 3415 th = 4312 ocn = 1542 (Fake hash codes) Anyway, the point is that I can use a service to convert a string into a collection of Int32 which I can use to create the associated hashes when creating the song and also when searching for songs which might have a similar name. I want to use a service obviously because it is used in 2 places (create song, find song). Now my initial thought was to create a constructor for Song like so public Song(string name, int[] wordHashes) { ... } and have a higher layer which creates the song also pass in the wordHashes, but I am a bit of a control freak when it comes to code and this feels like it is open to some other developer calling the constructor with the wrong word hashes (I work with developers who would do this deliberately if it was a simple solution to an isolated problem). So another thought was public Song(string name, IWordHashService wordHashService) { ... } but Unity IoC wont let me specify constants to pass to a constructor so that's not an option (fake example) IoC.ResolveSong(new { Name = My Bonnie lies over the occean }) So then the next option public Song(string name) { ... } [InjectionMethod] public void InjectDependencies(IWordHashService wordHashService) { ... } Obviously no good because the constructor will try to set the name before I have the service. Final option I can think of public class Song { IWordHashService WordHashService; public Song() { } [InjectionMethod] public void InjectDependencies(IWordHashService wordHashService) { WordHashService = wordHashService; } private string name; public string Name { get { return name; } set { name = value; //Calculate word hashes } } } This would work and is the kind of thing I would normally do, but in my current ORM I can mark a property so that it can no longer be updated once persisted so I can use this approach and still make Name immutible. In NH I am trying to make my classes completely persistence ignorant so I need an OOP way to make Name immutible, which is why I wanted to go for the Name in the constructor, although I suppose I could throw an exception if you try to set Name when it already has a value. I'm looking forward to seeing some opinions, and maybe some alternative ideas. Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
and as for the people asking about what the behaviour was - the simplest thing is to setup a quick two-entity domain with hilo id, new one instance of each, session.Save them both and peek into the generated data. As I am still at theory level and can't yet do that may I ask a question? :-) If I am about to save 50 new instances does it do something like Separate transaction select nextnumber from myidtable; update myidtable set nextnumber = nextnumber + 50; /Separate transaction Then assign nextnumber+X to each object about to be inserted? This is how I would guess it works, but the name Hi/Lo generator reminds me of an old strategy in which the user is allocated a range when the app starts and when they exhaust the range they request a new one, but it doesn't seem to me that it works that way so the name confuses me slightly :-) Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Regardless of transaction thing, HiLo assignes Id BEFORE it is sent to database. No select is executed. If lo value is maxLoValue then a new Hi is obtained but in another transaction. It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Mar 26, 2009 at 10:37 AM, Peter Morris mrpmor...@gmail.com wrote: and as for the people asking about what the behaviour was - the simplest thing is to setup a quick two-entity domain with hilo id, new one instance of each, session.Save them both and peek into the generated data. As I am still at theory level and can't yet do that may I ask a question? :-) If I am about to save 50 new instances does it do something like Separate transaction select nextnumber from myidtable; update myidtable set nextnumber = nextnumber + 50; /Separate transaction Then assign nextnumber+X to each object about to be inserted? This is how I would guess it works, but the name Hi/Lo generator reminds me of an old strategy in which the user is allocated a range when the app starts and when they exhaust the range they request a new one, but it doesn't seem to me that it works that way so the name confuses me slightly :-) Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
Haven't read the whole message (i will in a moment) but a quick answer would be did you try NH Search, or pure lucene indexing? No, neither, but I am mainly interested in the conceptual part of the question :-) Thanks Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] DB comments and description in NHibernate
I am working on a project where the database should be documented. I am looking for a way to use hibernate to define this in hibernate. I am using attributes on my classes to define my database (an example can be seen below). [NHibernate.Mapping.Attributes.Class(Table = LINK)] public partial class Link private Int32 _id; [NHibernate.Mapping.Attributes.Id(Name = Id, Column = ID)] [NHibernate.Mapping.Attributes.Generator(1, Class = sequence)] [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ)] public virtual Int32 Id { get { return this._id; } set { this._id = value; } } } ... } What I am looking for is something like: [NHibernate.Mapping.Attributes.Class(Table = LINK, Description=This is a table that keeps track of my links)] public partial class Link and [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ, Description=This is my primary key automatically generated by sequence number.)] public virtual Int32 Id --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Yes. Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Mar 26, 2009 at 11:40 AM, Ken Egozi egoz...@gmail.com wrote: as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
the way I understand it: a generated 64bit ID will consist of a HI and LO 32bit values (HI*32bit+LO) when a SessionFactory kicks in, it requests (and increments) the HI from the DB. as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on each new entity. On Thu, Mar 26, 2009 at 11:12 AM, Peter Morris mrpmor...@gmail.com wrote: It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: DB comments and description in NHibernate
afaik, Description is not available on all main RDBMS, thus NH is not supporting it. On Thu, Mar 26, 2009 at 11:47 AM, Utopico jardar.maa...@gmail.com wrote: I am working on a project where the database should be documented. I am looking for a way to use hibernate to define this in hibernate. I am using attributes on my classes to define my database (an example can be seen below). [NHibernate.Mapping.Attributes.Class(Table = LINK)] public partial class Link private Int32 _id; [NHibernate.Mapping.Attributes.Id(Name = Id, Column = ID)] [NHibernate.Mapping.Attributes.Generator(1, Class = sequence)] [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ)] public virtual Int32 Id { get { return this._id; } set { this._id = value; } } } ... } What I am looking for is something like: [NHibernate.Mapping.Attributes.Class(Table = LINK, Description=This is a table that keeps track of my links)] public partial class Link and [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ, Description=This is my primary key automatically generated by sequence number.)] public virtual Int32 Id -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: DB comments and description in NHibernate
Should be something like this in hbm-language To a table: class name=Customer comment my customer comment here/comment ... /class To a column: property name=Name column name=Name commentMy Name comment here /comment /column /property You should extrapolate this to those attributes, since are generated by the NH-schema, should be supported. The dialects with the option enabled are Oracle8iDialect on forward. On Thu, Mar 26, 2009 at 6:47 AM, Utopico jardar.maa...@gmail.com wrote: I am working on a project where the database should be documented. I am looking for a way to use hibernate to define this in hibernate. I am using attributes on my classes to define my database (an example can be seen below). [NHibernate.Mapping.Attributes.Class(Table = LINK)] public partial class Link private Int32 _id; [NHibernate.Mapping.Attributes.Id(Name = Id, Column = ID)] [NHibernate.Mapping.Attributes.Generator(1, Class = sequence)] [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ)] public virtual Int32 Id { get { return this._id; } set { this._id = value; } } } ... } What I am looking for is something like: [NHibernate.Mapping.Attributes.Class(Table = LINK, Description=This is a table that keeps track of my links)] public partial class Link and [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ, Description=This is my primary key automatically generated by sequence number.)] public virtual Int32 Id -- Dario Quintana http://darioquintana.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
While you have done your very best to try to find and edge case I think even this can be done without injecting to the entity. I have found very very few circumstances where an entity needed a non-transient dependency to something. The ones that I have found tend to be infrastructure type cross cutting concerns (logging as an example). Use a builder (nested class) and a private constructor... give the builder the service and have the service use the array overload that is on the private constructor. This is the point of the builder pattern. The only thing that you can say is wrong with that is that if there is a problem your coworkers will change the visibility on the constructor and then call it directly but frankly you have bigger problems at that point and should probably be seeking a competent team elsewheret. Greg On Thu, Mar 26, 2009 at 4:30 AM, Peter Morris mrpmor...@gmail.com wrote: Fabio gives the answer but do you really need to do it? Not sure :-) I have a Song class which has a Name property. When the user searches for a song I want to list songs with a similar name to what they entered rather than the exact string. To achieve this I am considering doing something like 1: Remove all characters so I only have consonants (except for first letters of words) 2: Remove all adjacent repeating letters 3: Convert to lower case 4: For each remaining word calculate a 32bit hash code For Song I will then have an association Song 1 *WordHash So My bonny lies over the occean would become my = 4622 bny = 6732 ls = 3623 ovr = 3415 th = 4312 ocn = 1542 (Fake hash codes) Anyway, the point is that I can use a service to convert a string into a collection of Int32 which I can use to create the associated hashes when creating the song and also when searching for songs which might have a similar name. I want to use a service obviously because it is used in 2 places (create song, find song). Now my initial thought was to create a constructor for Song like so public Song(string name, int[] wordHashes) { ... } and have a higher layer which creates the song also pass in the wordHashes, but I am a bit of a control freak when it comes to code and this feels like it is open to some other developer calling the constructor with the wrong word hashes (I work with developers who would do this deliberately if it was a simple solution to an isolated problem). So another thought was public Song(string name, IWordHashService wordHashService) { ... } but Unity IoC wont let me specify constants to pass to a constructor so that's not an option (fake example) IoC.ResolveSong(new { Name = My Bonnie lies over the occean }) So then the next option public Song(string name) { ... } [InjectionMethod] public void InjectDependencies(IWordHashService wordHashService) { ... } Obviously no good because the constructor will try to set the name before I have the service. Final option I can think of public class Song { IWordHashService WordHashService; public Song() { } [InjectionMethod] public void InjectDependencies(IWordHashService wordHashService) { WordHashService = wordHashService; } private string name; public string Name { get { return name; } set { name = value; //Calculate word hashes } } } This would work and is the kind of thing I would normally do, but in my current ORM I can mark a property so that it can no longer be updated once persisted so I can use this approach and still make Name immutible. In NH I am trying to make my classes completely persistence ignorant so I need an OOP way to make Name immutible, which is why I wanted to go for the Name in the constructor, although I suppose I could throw an exception if you try to set Name when it already has a value. I'm looking forward to seeing some opinions, and maybe some alternative ideas. Pete http://mrpmorris.blogspot.com -- It is the mark of an educated mind to be able to entertain a thought without accepting it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: DB comments and description in NHibernate
So it is a feature in the hbm-languague definition but not as attributes? If so is it possible to add this feature to the attributes in an easy way? On 26 Mar, 13:09, Dario Quintana conta...@darioquintana.com.ar wrote: Should be something like this in hbm-language To a table: class name=Customer comment my customer comment here/comment ... /class To a column: property name=Name column name=Name commentMy Name comment here /comment /column /property You should extrapolate this to those attributes, since are generated by the NH-schema, should be supported. The dialects with the option enabled are Oracle8iDialect on forward. On Thu, Mar 26, 2009 at 6:47 AM, Utopico jardar.maa...@gmail.com wrote: I am working on a project where the database should be documented. I am looking for a way to use hibernate to define this in hibernate. I am using attributes on my classes to define my database (an example can be seen below). [NHibernate.Mapping.Attributes.Class(Table = LINK)] public partial class Link private Int32 _id; [NHibernate.Mapping.Attributes.Id(Name = Id, Column = ID)] [NHibernate.Mapping.Attributes.Generator(1, Class = sequence)] [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ)] public virtual Int32 Id { get { return this._id; } set { this._id = value; } } } ... } What I am looking for is something like: [NHibernate.Mapping.Attributes.Class(Table = LINK, Description=This is a table that keeps track of my links)] public partial class Link and [NHibernate.Mapping.Attributes.Param(2, Name = sequence, Content = LINK_ID_SEQ, Description=This is my primary key automatically generated by sequence number.)] public virtual Int32 Id -- Dario Quintanahttp://darioquintana.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
I think that you can set Update=False, then the data will be selected and inserted, but not updated. with a readonly property and a factory method (or constructor) for setting the value for new instances you're set. On Thu, Mar 26, 2009 at 3:23 PM, Fabio Maulo fabioma...@gmail.com wrote: 2009/3/26 Peter Morris mrpmor...@gmail.com This would work and is the kind of thing I would normally do, but in my current ORM I can mark a property so that it can no longer be updated once persisted so I can use this approach and still make Name immutible. In NH I am trying to make my classes completely persistence ignorant so I need an OOP way to make Name immutible, which is why I wanted to go for the Name in the constructor, although I suppose I could throw an exception if you try to set Name when it already has a value. You can configure NH to use the field (including the backfield of an autoproperty) and don't have the setter. -- Fabio Maulo -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Ken, in NH is even better because it respect a sequence per table. An High is requested per sessionFactory per Persister... Example: Table-A: 101, 102,103,104..501,502 Table-B: 201, 202, 203, 204... 801,802 2009/3/26 Ken Egozi egoz...@gmail.com the way I understand it: a generated 64bit ID will consist of a HI and LO 32bit values (HI*32bit+LO) when a SessionFactory kicks in, it requests (and increments) the HI from the DB. as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on each new entity. On Thu, Mar 26, 2009 at 11:12 AM, Peter Morris mrpmor...@gmail.comwrote: It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Fabio Maulo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: DB comments and description in NHibernate
I didn't say that.Since NHMA use the mapping schema to generate the attributes, the option should be there. Maybe after the definition maybe your class will be having more metadata than code. On Thu, Mar 26, 2009 at 10:21 AM, Utopico jardar.maa...@gmail.com wrote: So it is a feature in the hbm-languague definition but not as attributes? If so is it possible to add this feature to the attributes in an easy way? -- Dario Quintana http://darioquintana.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Mapping Explicit Interface Properties with Same Name
That sure did it. Thanks again. This is going to make my life SO much easier. On Mar 26, 3:16 am, Stefan Steinegger stefan@bluewin.ch wrote: I really don't know, would have to try myself. Are there different columns for the properties? You probably should try to define a column name. On 26 Mrz., 05:19, Joshua jno...@gmail.com wrote: Thanks Stefan. I'm now able to implement one of the interface properties explicitly, but when I add the second I get: TestCase 'MappingTests.FooTests.Test' failed: System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.ThrowHelper.ThrowArgumentOutOfRangeException (ExceptionArgument argument, ExceptionResource resource) at System.ThrowHelper.ThrowArgumentOutOfRangeException() at System.Collections.Generic.List`1.get_Item(Int32 index) at System.Data.SQLite.SQLiteParameterCollection.GetParameter(Int32 index) at System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item (Int32 index) at NHibernate.Type.AbstractStringType.Set(IDbCommand cmd, Object value, Int32 index) at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value, Int32 index) at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value, Int32 index, Boolean[] settable, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate (Object id, Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 table, IDbCommand statement, ISessionImplementor session, Int32 index) at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate (Object id, Object[] fields, Boolean[] includeProperty, Boolean[][] includeColumns, Int32 j, IDbCommand st, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.GeneratedIdentifierBinder.BindValues (IDbCommand ps) at NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert (SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object [] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object [] fields, Object obj, ISessionImplementor session) at NHibernate.Action.EntityIdentityInsertAction.Execute() at NHibernate.Engine.ActionQueue.Execute(IExecutable executable) at NHibernate.Event.Default.AbstractSaveEventListener.PerformSaveOrReplicate (Object entity, EntityKey key, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) at NHibernate.Event.Default.AbstractSaveEventListener.PerformSave (Object entity, Object id, IEntityPersister persister, Boolean useIdentityColumn, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) at NHibernate.Event.Default.AbstractSaveEventListener.SaveWithGeneratedId (Object entity, String entityName, Object anything, IEventSource source, Boolean requiresImmediateIdAccess) at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.SaveWithGeneratedOrRequestedId (SaveOrUpdateEvent event) at NHibernate.Event.Default.DefaultSaveEventListener.SaveWithGeneratedOrRequestedId (SaveOrUpdateEvent event) at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.EntityIsTransient (SaveOrUpdateEvent event) at NHibernate.Event.Default.DefaultSaveEventListener.PerformSaveOrUpdate (SaveOrUpdateEvent event) at NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate (SaveOrUpdateEvent event) at NHibernate.Impl.SessionImpl.FireSave(SaveOrUpdateEvent event) at NHibernate.Impl.SessionImpl.Save(Object obj) mapping: ?xml version=1.0 encoding=utf-8 ? hibernate-mapping xmlns=urn:nhibernate-mapping-2.2 assembly=MappingTests namespace=MappingTests class name=ConcreteFoo id name=Id generator class=identity / /id property name=MappingTests.IFoo1.Foo / property name=MappingTests.IFoo2.Foo / /class /hibernate-mapping Appropriate parts of the test: ConcreteFoo foo = new ConcreteFoo(); ((IFoo1)foo).Foo = foo1; ((IFoo2)foo).Foo = foo2; session.Save(foo); Any ideas? I tried against SQL Server as well and got the same exception. This exception looks to me like NHibernate legitimately doesn't support explicit interface mapping with the same name. On Mar 25, 3:27 pm, Stefan Steinegger stefan@bluewin.ch wrote: I have to admit that I didn't read the whole thread. When using reflection, a explicit implementation of a property
[nhusers] Re: IoC into business class instances
Hi Fabio You can configure NH to use the field (including the backfield of an autoproperty) and don't have the setter. Thanks, I am aware of that, the problem is an OOP one really. If I don't have a setter then I wont be able to set the value without using a parameterised constructor, and then there were problems with constructors. The problems weren't really persistence related at all. Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
Hi Anne Regarding your actual algorithm, it sounds like you're making something very similar to soundex. Yes, it is basically that, for now at least. I will look at what algorithm I will use when I am happy with the approach. Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
Hi Greg While you have done your very best to try to find and edge case I'm not actually looking for a corner case here I'm just trying to find a way to implement what I currently need, but it does make me wonder about injecting dependencies into my domain. Surely there are circumstances where the domain is going to need services injected, as you say like Logging. How would I inject a logging dependency? I have found very very few circumstances where an entity needed a non-transient dependency to something. Did you mean persistent or transient? I need a transient dependency to a service. Use a builder (nested class) and a private constructor... give the builder the service and have the service use the array overload that is on the private constructor. Do you mean something like this? public class Song { public class SongBuilder { IWordHashService WordHashService; public SongBuilder(IWordHashService wordHashService) { WordHashService = wordHashService; } public Song CreateSong(string name) { return new Song(name, WordHashService); } } IWordHashService WordHashService; private Song(string name, IWordHashService wordHashService) { //Validate Name Name = name; WordHashService = wordHashService; } private string name; public string Name { get { return name; } } } Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
I have found very very few circumstances where an entity needed a non-transient dependency to something. Did you mean persistent or transient? I need a transient dependency to a service. Not surprisingly I am using the definition of transient itself not refering to a transient vs persistent object. In other words for 95+% of cases the object does not need to *remember* which service to use, it just needs to be given one for the duration of an operation. These can be handled through double dispatch ... Your code example is slightly off ... the builder should not be handing the service to the object but should be using the service to get the data to pass to the object. On Thu, Mar 26, 2009 at 10:58 AM, Peter Morris mrpmor...@gmail.com wrote: Hi Greg While you have done your very best to try to find and edge case I'm not actually looking for a corner case here I'm just trying to find a way to implement what I currently need, but it does make me wonder about injecting dependencies into my domain. Surely there are circumstances where the domain is going to need services injected, as you say like Logging. How would I inject a logging dependency? I have found very very few circumstances where an entity needed a non-transient dependency to something. Did you mean persistent or transient? I need a transient dependency to a service. Use a builder (nested class) and a private constructor... give the builder the service and have the service use the array overload that is on the private constructor. Do you mean something like this? public class Song { public class SongBuilder { IWordHashService WordHashService; public SongBuilder(IWordHashService wordHashService) { WordHashService = wordHashService; } public Song CreateSong(string name) { return new Song(name, WordHashService); } } IWordHashService WordHashService; private Song(string name, IWordHashService wordHashService) { //Validate Name Name = name; WordHashService = wordHashService; } private string name; public string Name { get { return name; } } } Pete http://mrpmorris.blogspot.com -- It is the mark of an educated mind to be able to entertain a thought without accepting it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] 2 collections of the same entity
Hi, I'm trying to map 2 collections of the same entity, but when I load the data from the database, both collections have the same entities, because they map the same key column... Here is a sample code part similar to mine, where a School has 2 collections of Students, the Boys and the Girls collections: ... bag name=Boys generic=true table=`tblStudents` inverse=true cascade=all-delete-orphan key column =`IdSchool`/key one-to-many class =Eg.Student,Eg / /bag bag name=Girls generic=true table=`tblStudents` inverse=true cascade=all-delete-orphan key column =`IdSchool`/key one-to-many class =Eg.Student,Eg / /bag ... How can I map this collections correctly? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: 2 collections of the same entity
hmm maybe: where Gender='laddie' / where Gender='lassie' On Thu, Mar 26, 2009 at 5:09 PM, Joao joaocr...@gmail.com wrote: Hi, I'm trying to map 2 collections of the same entity, but when I load the data from the database, both collections have the same entities, because they map the same key column... Here is a sample code part similar to mine, where a School has 2 collections of Students, the Boys and the Girls collections: ... bag name=Boys generic=true table=`tblStudents` inverse=true cascade=all-delete-orphan key column =`IdSchool`/key one-to-many class =Eg.Student,Eg / /bag bag name=Girls generic=true table=`tblStudents` inverse=true cascade=all-delete-orphan key column =`IdSchool`/key one-to-many class =Eg.Student,Eg / /bag ... How can I map this collections correctly? -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: NH Spatial compatible with NH2.1
Same question... On 20 fev, 08:39, stachu mailing...@gmail.com wrote: Hi! I found NHSpatialvery interesting and promesing. I wanted to give it a try but I noticed that it's build against NH2.0.1. However at work we use NH2.1 and it tried to build NHSP with it but it failed. My question is if you are planning to upgrade it in near future? Best regards Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Subqueries DetachedCriteria and SetMaxResult
This is simple example, originary code is Code: var a_DetachedCriteria = DetachedCriteria.ForUserDO(); a_DetachedCriteria .SetProjection(Property.ForName(ID)) .AddUserDO(x = x.Login == a_UserLogon) .AddUserDO(u = u.Password == a_UserPsw) .AddUserDO(u = u.Status == UserStatus.Actual) .SetMaxResults(1); IListUserDO a_UserLst = DataProviderNative.Session.CreateCriteriaUserDO() .Instance .Add(Subqueries.PropertyIn(ID,a_DetachedCriteria)) .ListUserDO(); As result of code, Nhibernate generate the sql with missing parameter: SELECT this_.ID AS id16_0_, this_.VERSION AS version16_0_, this_.login AS login16_0_, this_.PASSWORD AS password16_0_, this_.surname AS surname16_0_, this_.firstname AS firstname16_0_, this_.patronymic AS patronymic16_0_, this_.job AS job16_0_, this_.privatecode AS privatec9_16_0_, this_.organisation AS organis10_16_0_, this_.phone AS phone16_0_, this_.email AS email16_0_, this_.info AS info16_0_, this_.status AS status16_0_, this_.official AS official16_0_ FROM adm$user this_ WHERE this_.ID IN ( SELECT * FROM (SELECT this_0_.ID AS y0_ FROM adm$user this_0_ WHERE this_0_.login = :p0 AND this_0_.PASSWORD = :p1 AND this_0_.status = :p2) WHERE ROWNUM = :p3 ) ; :p0 = 'admin', :p1 = 'admin', :p2 = '5' Parameter :p3 are missing. What do I do wrong or am I just missing something? Any comments? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Linq2nhibernate soundex?
Hi all, I did a quick scan but couldnt find static methods to use the soundex function in linq2nhib. Have I missed it or is it just not implemented? Thanks, Seb _ 25GB of FREE Online Storage – Find out more http://clk.atdmt.com/UKM/go/134665320/direct/01/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Please excuse my ignorance, but can the high table reads/increments ever become a performance bottleneck since every session factory has to do a read/increment on the same table/column? I'm guessing that maybe in theory the answer is yes, but in practicality the answer is no. On Mar 26, 8:32 am, Fabio Maulo fabioma...@gmail.com wrote: Ken, in NH is even better because it respect a sequence per table. An High is requested per sessionFactory per Persister... Example: Table-A: 101, 102,103,104..501,502 Table-B: 201, 202, 203, 204... 801,802 2009/3/26 Ken Egozi egoz...@gmail.com the way I understand it: a generated 64bit ID will consist of a HI and LO 32bit values (HI*32bit+LO) when a SessionFactory kicks in, it requests (and increments) the HI from the DB. as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on each new entity. On Thu, Mar 26, 2009 at 11:12 AM, Peter Morris mrpmor...@gmail.comwrote: It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Fabio Maulo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Linq2nhibernate soundex?
not implemented. However, you can use your own functions, but i don't remember how. Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Mar 26, 2009 at 11:10 AM, Sebastien Lambla s...@serialseb.comwrote: I did a quick scan but couldnt find static methods to use the soundex function in linq2nhib. Have I missed it or is it just not implemented? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
The Hi values are read once (until lo becomes larger than int16.Max(default) I don't ever think it becomes a bottleneck. Tuna Toksöz Eternal sunshine of the open source mind. http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Thu, Mar 26, 2009 at 6:27 PM, Daniel Auger daniel.au...@gmail.comwrote: ever become a performance bottleneck since every session factory has --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: NH Spatial compatible with NH2.1
You can ask by a ticket here: http://nhjira.koah.net/browse/NHSP On Thu, Mar 26, 2009 at 12:47 PM, Bruno brunomalu...@gmail.com wrote: Same question... On 20 fev, 08:39, stachu mailing...@gmail.com wrote: Hi! I found NHSpatialvery interesting and promesing. I wanted to give it a try but I noticed that it's build against NH2.0.1. However at work we use NH2.1 and it tried to build NHSP with it but it failed. My question is if you are planning to upgrade it in near future? Best regards Mike -- Dario Quintana http://darioquintana.com.ar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: IoC into business class instances
Did you mean persistent or transient? I need a transient dependency to a service. Not surprisingly I am using the definition of transient itself not refering to a transient vs persistent object. In other words for 95+% of cases the object does not need to *remember* which service to use, it just needs to be given one for the duration of an operation. Oh right. It was somewhat confusing because we are discussing ORM which has transient and persistent members, and IoC which (in Unity at least) as controller lifetime services and transient services. So I had no idea what you were talking about :-) These can be handled through double dispatch ... I could have public void SetName(string Name, IWordHashService wordHashService) but then I would have to resolve the service myself, and I really like all of that to be done for me. I do have places where I have services as parameters on methods and I don't like it, it just seems wrong to me, especially when there are a few services. Having these services automagically available is more appealing. Your code example is slightly off ... the builder should not be handing the service to the object but should be using the service to get the data to pass to the object. Yes, that makes sense. So you mean something like this? public class Song { public class SongBuilder { IWordHashService WordHashService; public SongBuilder(IWordHashService wordHashService) { WordHashService = wordHashService; } public Song CreateSong(string name) { return new Song(name, WordHashService.CreateWordHashes(name)); } } IWordHashService WordHashService; private Song(string name, int[] wordHashes) { //Validate Name Name = name; //Store the word hashes } private string name; public string Name { get { return name; } } } And use it like so Song = container.ResolveSong.SongBuilder().CreateSong(Meh); Is that what you mean? Pete http://mrpmorris.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Example scenario: - Web farm with 20 servers - ASP.NET app using SessionFactory singleton pattern It would seem then that only 20 different things would interested in the hi table, and that selects/increments would not be happening too often with the default maxlow options. That seems quite scalable to me. On Mar 26, 11:38 am, Fabio Maulo fabioma...@gmail.com wrote: Well... it depend, if you are creating a session-factory for each persistence action, the the round-trip to read the High value is only your last concern. The roundtrip happen only one time per-session-factory per-table (inside maxlow, obviously) 2009/3/26 Daniel Auger daniel.au...@gmail.com Please excuse my ignorance, but can the high table reads/increments ever become a performance bottleneck since every session factory has to do a read/increment on the same table/column? I'm guessing that maybe in theory the answer is yes, but in practicality the answer is no. On Mar 26, 8:32 am, Fabio Maulo fabioma...@gmail.com wrote: Ken, in NH is even better because it respect a sequence per table. An High is requested per sessionFactory per Persister... Example: Table-A: 101, 102,103,104..501,502 Table-B: 201, 202, 203, 204... 801,802 2009/3/26 Ken Egozi egoz...@gmail.com the way I understand it: a generated 64bit ID will consist of a HI and LO 32bit values (HI*32bit+LO) when a SessionFactory kicks in, it requests (and increments) the HI from the DB. as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on each new entity. On Thu, Mar 26, 2009 at 11:12 AM, Peter Morris mrpmor...@gmail.com wrote: It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Fabio Maulo -- Fabio Maulo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Using Hi/Lo Generator
Try to study how HighLow are working in NH.You will see that you have only two better options: guid.comb : no round-trips because assigned in client side assigned : you custom ID assigned by your application; no round-trips because assigned in client side After that HighLow is the better option if you want work using Int32 or Int64 as POID. Inside a SessionFactory instance HighLow has a round-trip per-RootPersister each 32767 inserts (by default). 2009/3/26 Daniel Auger daniel.au...@gmail.com Example scenario: - Web farm with 20 servers - ASP.NET app using SessionFactory singleton pattern It would seem then that only 20 different things would interested in the hi table, and that selects/increments would not be happening too often with the default maxlow options. That seems quite scalable to me. On Mar 26, 11:38 am, Fabio Maulo fabioma...@gmail.com wrote: Well... it depend, if you are creating a session-factory for each persistence action, the the round-trip to read the High value is only your last concern. The roundtrip happen only one time per-session-factory per-table (inside maxlow, obviously) 2009/3/26 Daniel Auger daniel.au...@gmail.com Please excuse my ignorance, but can the high table reads/increments ever become a performance bottleneck since every session factory has to do a read/increment on the same table/column? I'm guessing that maybe in theory the answer is yes, but in practicality the answer is no. On Mar 26, 8:32 am, Fabio Maulo fabioma...@gmail.com wrote: Ken, in NH is even better because it respect a sequence per table. An High is requested per sessionFactory per Persister... Example: Table-A: 101, 102,103,104..501,502 Table-B: 201, 202, 203, 204... 801,802 2009/3/26 Ken Egozi egoz...@gmail.com the way I understand it: a generated 64bit ID will consist of a HI and LO 32bit values (HI*32bit+LO) when a SessionFactory kicks in, it requests (and increments) the HI from the DB. as an outcome - every SessionFactory gets a range (using the HI) then increments the LO on each new entity. On Thu, Mar 26, 2009 at 11:12 AM, Peter Morris mrpmor...@gmail.com wrote: It is the thing that you last said, when exhaust a new Hi value is obtained, Lo values are incremented everytime an object is persisted. Ah I see, that makes sense. I am confusing it with the other approach where only the exact number of IDs are requested when an update is required. Pete http://mrpmorris.blogspot.com -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il -- Fabio Maulo -- Fabio Maulo -- Fabio Maulo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: 2 collections of the same entity
If you are working with a legacy database (equals you can not modify the tables) then you should take Ken's approach. If not, and you can modify the tables, you need 2 IDs in the TblStudent, and your mappings would be (note the inverse false and the column names): ... bag name=Boys generic=true table=`tblStudents` inverse=false cascade=all-delete-orphan key column =`IdSchool1`/key one-to-many class =Eg.Student,Eg / /bag bag name=Girls generic=true table=`tblStudents` inverse=false cascade=all-delete-orphan key column =`IdSchool2`/key one-to-many class =Eg.Student,Eg / /bag ... This way you have unidirectional navigation from School to Boys or Girls collection. If you need additional bidirectional navigation, you can always add a new many-to-one to School from students, and add a third ID in TblStudents. ... many-to-one name=School column=IdSchool class=Eg.School, Eg not- null=true lazy=false /many-to-one ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] LockMode.Upgrade Question
Hello, I am using the LockMode.Upgrade lock mode on a query to prevent concurrent access to a row. Using a simple test case with 2 Sessions I can see that Session 2 will not execute it's query until Session 1 commits it's transaction, but in our application we are seeing something strange. The code is: IQuery query = session.CreateQuery(from TransactionNumberContainer tnc where tnc.TrtTransactionType.TrtId = :type + and tnc.TrtProperty.Id = :prop) .SetParameter(type, tType.TrtId) .SetParameter(prop, property.Id); query.SetLockMode(tnc, LockMode.Upgrade); logger.ErrorFormat(** ( REQUESTING ) LOCK ON TNC: THREAD {0} ***, Thread.CurrentThread.ManagedThreadId); return query.UniqueResultTransactionNumberContainer(); Using 2 Internet Explorer windows I am sending in 2 requests / sessions to this code and was expecting to see that the second session blocks until the first commits, but I am seeing both go through sequentially before either transaction commits. In addition, the sql in the profiler is DIFFERENT for the second session. Can someone explain this (this is causing deadlocks as well as data integrity issues for us)? Thanks, Aaron: Sql from Session 1: exec sp_executesql N'select transactio0_.TNC_TRT_ID as TNC1_77_, transactio0_.TNC_PRP_ID as TNC2_77_, transactio0_.TNC_VERSION as TNC3_77_, transactio0_.TNC_RCD_USR_ID as TNC4_77_, transactio0_.TNC_REV_USR_ID as TNC5_77_, transactio0_.TNC_RCD_DATE as TNC6_77_, transactio0_.TNC_REV_DATE as TNC7_77_, transactio0_.TNC_RCD_URL_ORIGIN as TNC8_77_, transactio0_.TNC_REV_URL_ORIGIN as TNC9_77_, transactio0_.TNC_PREFIX as TNC10_77_, transactio0_.TNC_CURRENT_NBR as TNC11_77_ from dbo.TRANSACTION_NUMBER_CONTAINER transactio0_ with (updlock, rowlock) where (transactio0_.tnc_trt_...@p0 )and (transactio0_.tnc_prp_...@p1 )',N'@p0 int,@p1 int',@p0=1,@p1=3 Sql from Session 2 (same code above): exec sp_executesql N'SELECT transactio0_.TNC_TRT_ID as TNC1_77_0_, transactio0_.TNC_PRP_ID as TNC2_77_0_, transactio0_.TNC_VERSION as TNC3_77_0_, transactio0_.TNC_RCD_USR_ID as TNC4_77_0_, transactio0_.TNC_REV_USR_ID as TNC5_77_0_, transactio0_.TNC_RCD_DATE as TNC6_77_0_, transactio0_.TNC_REV_DATE as TNC7_77_0_, transactio0_.TNC_RCD_URL_ORIGIN as TNC8_77_0_, transactio0_.TNC_REV_URL_ORIGIN as TNC9_77_0_, transactio0_.TNC_PREFIX as TNC10_77_0_, transactio0_.TNC_CURRENT_NBR as TNC11_77_0_ FROM dbo.TRANSACTION_NUMBER_CONTAINER transactio0_ WHERE transactio0_.tnc_trt_...@p0 and transactio0_.tnc_prp_...@p1',N'@p0 int,@p1 int',@p0=1,@p1=3 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Problems querying with NHibernate + Lucene.Net
Can anyone help out a newbie? I've been working at getting NHibernate + Lucene.Net working together. I've got indexes built on a few fields of a single class - correctly, as far as I can tell - but I've been unable to build a query that returns results. Here's a snippet: var parser = new QueryParser(field, new StandardAnalyzer()); Lucene.Net.Search.Query luceneQuery = parser.Parse(searchCriteria); IFullTextSession fts = Search.CreateFullTextSession(session); IQuery qry = fts.CreateFullTextQuery(luceneQuery, typeof (Customer)); var found = qry.List(); field is City (which is the indexed property name). I've tried with different searchCriteria - in one test, I use James, which I know should return results, as SELECT * FROM Customer WHERE city LIKE %James% returns results. Once the qry object is instantiated, qry.QueryString=City:James, which is correct (I believe). Looking at qry.ReturnTypes in the Visual Studio raises an NHibernate.QueryException. Other than this one, no exceptions are raised that I have noted. If I trace through the call to qry.List(), the Lucene Query instance instantiated at: Query query = FullTextSearchHelper.FilterQueryByClasses (classesAndSubclasses, luceneQuery); is a BooleanQuery with two clauses: {+City:james} {+(_hibernate_class:MyProject.Domain.Customer, MyProject, Version=0.2.3372.26162, Culture=neutral, PublicKeyToken=null)^.0} Can anyone point me in the right direction, suggest things to look for? Until two days ago, I had never set eyes on Lucene.Net; I don't much know my way around it yet. I'm not sure where the problem lies; everything seems to be running fine, except that I fail to find any results. Thanks, Remi. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Proxy cast problem for base object, not proxied property
All, I'm getting a weird problem - I'm doing the following call: ILocation loc = Session.GetLocation(id); and NH is throwing this error: Exception Unable to cast object of type 'INHibernateProxyProxy2183142372c34751a1aceee41a501ee3' to type 'Intellident.Core.Domains.Location'. at NHibernate.Impl.SessionImpl.Get[T](Object id) at Intellident.Core.Repository.NHibernate.NHibernateRepository.Get [T](Guid key) in ... There are no proxies involved in this. This seems to happen in a certain situation with data but I can't narrow it down yet. How can I be getting a proxy error with this anyway... no proxies are involved for this type of call surely? I'd try a GetILocation but NH doesn't let me do that with themapping below as I get a no persister exception. I can add to the mapping (e.g. some kind of alias ?) but I can't replace the class name-Location with ILocation. Mapping file for location: ?xml version=1.0 encoding=utf-8 ? hibernate-mapping xmlns=urn:nhibernate-mapping-2.2 namespace=Core.Domains assembly=Core.Domains default-access=field.camelcase-underscore default-lazy=true class name=Location proxy=Core.Domains.Interfaces.ILocation, Core.Domains.Interfaces table=Location discriminator-value=0 id name=Id column=Id unsaved- value=---- access=property generator class=guid.comb / /id discriminator column=Discriminator type=byte not-null=true / version name=Version column=Version type=binary unsaved- value=null generated=always/ property name=Name type=string length=255 not-null=true / many-to-one name=Parent column=ParentId class=Location / many-to-one name=Category column=LocationCategoryId class=LocationCategory not-null=true / bag name=SubLocations inverse=true cascade=delete optimistic-lock=false key column=ParentId / one-to-many class=Location / /bag bag name=Readers inverse=true cascade=none optimistic- lock=false key column=LocationId on-delete=cascade / one-to-many class=Intellident.Core.Domains.Hardware.ReaderComponent / /bag bag name=MovementsTo inverse=true cascade=delete optimistic- lock=false key column=ToId / one-to-many class=Movement / /bag bag name=MovementsFrom inverse=true cascade=delete optimistic-lock=false key column=FromId / one-to-many class=Movement / /bag /class /hibernate-mapping --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: TimeSpan 24h or 0h
Hi all. I agree with Oskar, Roger and Jay. Timespan is conceptually a duration (time interval), not a time. We use it to express age like 1h, 24h, 7days, 1month etc. Using it as a time is a very special case that should be explicit. After all because it reduces the value range massively. You wouldn't map an integer to a byte by default, would you? On Mar 25, 10:28 pm, Oskar Berggren oskar.bergg...@gmail.com wrote: Thanks Dario for you clarification above. I have created issue NH-1716 to request that the default remain as the old behaviour. A few additional notes: One could argue that if you are database centric and already have a column of type TIME it is not entirely unreasonable to handle this as a TimeSpan in an application, since MS didn't bother to create a System.Time at the same time they did the System.DateTimeOffset. However, if you are domain model centric and use TimeSpan because you really want to, the most reasonable default persisting of this should be the one least limiting. And the default in NHibernate should be to best support the domain model approach right? Regards, Oskar 2009/3/25 Dario Quintana conta...@darioquintana.com.ar To @Roger and @Jay: I don't have complains to vote for who is the default. We were asking to the community for that, the point was that we got any answer. But who is default is another issue in the Jira. Cheers. -- Dario Quintana --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Problems querying with NHibernate + Lucene.Net
Visual Studio raises an NHibernate.QueryException Can you post exception details ? On Mar 26, 7:55 pm, Rémi r...@terracognita.ca wrote: Can anyone help out a newbie? I've been working at getting NHibernate + Lucene.Net working together. I've got indexes built on a few fields of a single class - correctly, as far as I can tell - but I've been unable to build a query that returns results. Here's a snippet: var parser = new QueryParser(field, new StandardAnalyzer()); Lucene.Net.Search.Query luceneQuery = parser.Parse(searchCriteria); IFullTextSession fts = Search.CreateFullTextSession(session); IQuery qry = fts.CreateFullTextQuery(luceneQuery, typeof (Customer)); var found = qry.List(); field is City (which is the indexed property name). I've tried with different searchCriteria - in one test, I use James, which I know should return results, as SELECT * FROM Customer WHERE city LIKE %James% returns results. Once the qry object is instantiated, qry.QueryString=City:James, which is correct (I believe). Looking at qry.ReturnTypes in the Visual Studio raises an NHibernate.QueryException. Other than this one, no exceptions are raised that I have noted. If I trace through the call to qry.List(), the Lucene Query instance instantiated at: Query query = FullTextSearchHelper.FilterQueryByClasses (classesAndSubclasses, luceneQuery); is a BooleanQuery with two clauses: {+City:james} {+(_hibernate_class:MyProject.Domain.Customer, MyProject, Version=0.2.3372.26162, Culture=neutral, PublicKeyToken=null)^.0} Can anyone point me in the right direction, suggest things to look for? Until two days ago, I had never set eyes on Lucene.Net; I don't much know my way around it yet. I'm not sure where the problem lies; everything seems to be running fine, except that I fail to find any results. Thanks, Remi. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Persisting to flat files rather than a database
or maybe sqlite/whatever-embedded may be granted as 'flat file' too ;) On Mar 25, 1:01 pm, x97mdr jeffreycame...@gmail.com wrote: Has anyone ever used NHibernate (say with the text odbc drivers) to persist their information to a set of flat files in addition to a database? The reason I ask is that my application can retrieve information from either a set of flat files OR a database. I can use NHibernate for the database part but if possible it would be cool to use it with the flat file part too. If it can't happen then no big deal, I can always write the stuff myself but I thought I would ask in case anyone has had this problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] NHibernate Search with Integer Fields
Hi, I have the following failing test: using (var sess = Container.ResolveISessionFactory().OpenSession()) { using (IFullTextSession fullTextSession = NHibernate.Search.Search.CreateFullTextSession(sess)) { Page page = new Page { Title = mypage, OwnerId = 1 }; Page page2 = new Page { Title = mypage, OwnerId = 2 }; fullTextSession.Save(page); fullTextSession.Save(page2); fullTextSession.Clear(); Query query = new QueryParser(Title, new SimpleAnalyzer()).Parse (OwnerId:1); var result = fullTextSession.CreateFullTextQuery(query, typeof (Page)).ListPage(); Assert.AreEqual(1, result.Count); } } The problem is that it brings back zero records. On the OwnerId I have: [Field(Index.Tokenized, Store = Store.Yes)] public virtual int OwnerId { get; set; } I am unsure where the problem lies here and I hope for some advice. I'm not even sure if this is the correct way to achieve what I want - in actual fact I will be querying against the Title but I want to filter based on OwnerId too. I would definitely appreciate any suggestions. Best, Colin. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Re: Problems querying with NHibernate + Lucene.Net
Looking into this further, I found Luke, the Lucene Index Toolbox, which has allowed me to look at my index and try some ad-hoc queries. I've found a few things which I'm wondering about... I rebuilt the index tonight, and I've noticed that my project version was updated from 0.2.3372.26162 to 0.2.3372.36855, which is not a surprise. While working with Visual Studio, revision and build numbers are typically updated automatically due to the assembly's AssemblyVersion property ending in *: [assembly: AssemblyVersion(0.2.*)] Could this be at the root of my searching problem? With every build, my assembly version number is updated, which no longer matches the assembly version noted in the index? Secondly, in Luke, I've found that searching for City:James and City:james does not return the same results. My data has the capital J - I guess the index lowercases everything? Thanks, Remi. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] Intellisense nhibernate.dll
Hi, I'm fairly new to NHibernate and I've just got my first sample application running. I'm using Visual c++ (.net framework 3.5 sp1), visual studio express 2008. VS studio does not perform code completion on code statements involving the NHibernate classes/namespaces, e.g. intellisense does not show anything after 'NHibernate::' . In fact the NHibernate namespace isn't listed in the intellisense list. In the object explorer I can explore the various namespaces and classes within the NHibernate.dll. The log4net and castle dll's that come with the distribution work fine with intellisense. I have tried the following: - delete the ncb file and let intellisense rebuild it again. - download NHibernate 2.1 alpha (2.1.0.1001) to replace 2.0.1GA Thanks for any help on this one. Joost --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---
[nhusers] nhibernate mapping iset and bag
I have a simple many to many association like below 1.User(UserId) 2.UserProjects(UserId,ProjectId,RowId) 3.Projects(ProjectId) When I do a mapping with many to many with a bag collection of Users in Projects the nhibernate query generated for adding a user to project turns out to be Dim p as Project = ProjectRepository.GetById(1) Dim u as User = UserRepositoy.GetUser(Yuvan) p.Users.Add(u) p.SaveorUpdate() [Note I already have users asscoiated with the project] Nhibernate Query : Delete From UserProject Where ProjectId=1 Nhibernate Query : Insert into UserProject(1,Yuvan) Nhibernate Query : Insert into UserProject( ) Nhibernate Query : Insert into UserProject( ) When I do a mapping with a Iset collection there is no issues.Only one insert for the newly associated user. I do lazy loading for all collections and my cascades are set properly. So is this how bag collection works for many-to-many mapping ( deletes all the rows in the association table and do an insert) or is that I am missing something. I see a lot of docs and online examples using bag for the many-to-many??However when I use bags for one-to-many mapping and add/change collections I dont see this behaviour?? Can someone out there please explain me why???Please --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~--~~~~--~~--~--~---