[nhusers] Re: Inheritance: searching for baseclass and find out specialized class

2009-06-18 Thread jobsamuel
Suppose you do a query like "from Customer" it will give you both GoodCustomer and BadCustomer as you are querying the base class. You can check which one it is using the type of object. --~--~-~--~~~---~--~~ You received this message because you are subscribed to t

[nhusers] Re: Collections on Domain Models vs. "GetListBy" Methods on DAOs?

2009-06-18 Thread brendanjerwin
Thanks. That helps me out. On Jun 18, 3:39 pm, Gustavo Ringel wrote: > Fabio's rule of thumb is "avoid to put a collection in a class if changing > to lazy="false" will cause problems". > You don't want a collection of thousand of elements there or some chain of > collections being loaded sudden

[nhusers] deep copy aggregate root

2009-06-18 Thread Tyler Burd
I have a need to deep copy an object graph and have the copy routine follow the cascade settings in the class's mapping file. Basically, for every collection and property marked cascade="", I need to also deep copy that object, preferably resetting the primary key property to the unsaved-value

[nhusers] SQLite connection string

2009-06-18 Thread Sanky
I need some help in identifying the default location for the SQLite database. I do not want to specify the complete path for my database as it always has to be next to the EXE. If the example below has to work - where ABC.sqliteDB needs to be located? Please note that I have not specified the abs

[nhusers] Re: Linq to NHibernate Problem (Not Obeying Where Clause)

2009-06-18 Thread ChrisHolmes
You were close! Thank you for pointing the way! It needed to be: query = query.Where(criterion).AsQueryable(); -Chris On Jun 18, 2:18 pm, Tuna Toksoz wrote: > query.Where(criterion); > > is the problematic stuff. > > try > > query=query.Where(criterion) > > talking from memory, though. > > Tu

[nhusers] Re: Linq to NHibernate Problem (Not Obeying Where Clause)

2009-06-18 Thread Tuna Toksoz
query.Where(criterion); is the problematic stuff. try query=query.Where(criterion) talking from memory, though. 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, Jun 18, 2009 at 11:52 PM, Chr

[nhusers] Re: inner join

2009-06-18 Thread cws
I was thinking that the parser would allow it? On 18 Juni, 22:45, cws wrote: > Hi! > > I can't do something like this with hql can i? > > from Lecture outerLektion >         inner join (select DateOnly(l.Time) as date >         from Lecture l >         where outerLektion.Time = l.Time and l.Time

[nhusers] Many-to-one entity not hydrated from second level cache

2009-06-18 Thread Tolomaüs
Hi, I'm in the middle of adding second level caching to an existing application and this is the first time that I really touch this - quite interesting - topic. Basically, what I want to do in this first phase is to pre-load all referential data (i.e. the slowly changing stuff) when the session

[nhusers] Linq to NHibernate Problem (Not Obeying Where Clause)

2009-06-18 Thread ChrisHolmes
I am using the Nhibernate.Linq binary from NHibernate Contrib. I have the following class definition: public class Repository : IRepository { public IList FindAll(IList> criteria) { ISession session = SessionManager.GetCurrentSession(); IQueryable q

[nhusers] inner join

2009-06-18 Thread cws
Hi! I can't do something like this with hql can i? from Lecture outerLektion inner join (select DateOnly(l.Time) as date from Lecture l where outerLektion.Time = l.Time and l.Time between :StartDate and :EndDate group by DateOnly(l.Time) having minute((max

[nhusers] Re: Is SQLite.NET supporting multiple schemes?

2009-06-18 Thread Steve Wagner
What about change the dialect of database which dose not support schema to generate tables like this: schamaname_tablename This would resolve this problem after all. -Steve Fabio Maulo schrieb: > I read this matter various times, to express my opinion I have two question: > How much accurate

[nhusers] Re: Collections on Domain Models vs. "GetListBy" Methods on DAOs?

2009-06-18 Thread Gustavo Ringel
Fabio's rule of thumb is "avoid to put a collection in a class if changing to lazy="false" will cause problems". You don't want a collection of thousand of elements there or some chain of collections being loaded suddenly. You can do some tricks to have the property for queries as blogged here: ht

[nhusers] Inheritance: searching for baseclass and find out specialized class

2009-06-18 Thread Paulo Quicoli
Hi friends! i have an inheritance: Customer is base class for GoodCustomer and BadCustomer * these are fictial name classes, just for illustrations I've mapped that as a single table like this:

[nhusers] Collections on Domain Models vs. "GetListBy" Methods on DAOs?

2009-06-18 Thread brendanjerwin
I'm trying to decide on a course of action. Currently, I tend to have a fairly large number of collections hanging off my Domain Models: Organization.Locations I'm starting to suspect, though, that another pattern might be better: LocationDao.GetLocationsByParentOrganization(parentOrganization)

[nhusers] Re: Deleting Child Items

2009-06-18 Thread Fabio Maulo
Well done JoshThis is the right spirit... when somebody found a solution to a problem the right thing to do is share it as he share the problem. Thanks. 2009/6/18 joshlrogers > > Sorry just a minute or two after I wrote this I figured it out. Here > is what I did wrong: > > First, on my map

[nhusers] Re: Deleting Child Items

2009-06-18 Thread joshlrogers
Sorry just a minute or two after I wrote this I figured it out. Here is what I did wrong: First, on my mapping I did not specify that it was an inverse, I got that little nugget of information from here: http://gregdoesit.com/2009/01/deleting-a-one-to-many-relationship-in-nhibernate/ Second, on

[nhusers] Deleting Child Items

2009-06-18 Thread joshlrogers
I have a class/table that has a collection(IList) of details. I am trying to get NHibernate to delete these details when I remove them from the collection. So...simply I am trying to do this... 1. Clear (.Clear()) or Remove (.Remove(JobDetail)) from the class 2. Call Update on the class to upda

[nhusers] Re: impoving startup time of nhibernate

2009-06-18 Thread Chris Nicola
I put together a solution based on the Castle one from nhforge, but doesn't require you to have Castle. You can read it here: http://www.lucisferre.org/index.php/2009/06/18/speed-up-nhibernate-startup-with-object-serialization?blog=2 . It isn't anything that hard, but I hope it is useful to people

[nhusers] Re: Handling Bidirectional Many-To-Many Relationships

2009-06-18 Thread epitka
Maybe you should re-think the way you handle many-to-may and try to reduce it to one-to-many. Check this arcticle that explains how to do it. http://www.udidahan.com/2009/01/24/ddd-many-to-many-object-relational-mapping/ On Jun 16, 2:34 am, J M wrote: > Core question: What is the preferred way

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Skafa
@Fabio, yeah. it's a hype, and people keep copy/pasting this. On 18 jun, 14:56, Fabio Maulo wrote: > Right Skafa. I saw a lot IReposity that are really IDao ...but you > know... IReposity has another fashion meaning ;) > > 2009/6/18 Skafa > > > > > > > If you use a 'repository' to abstract a

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Peter Morris
I favour having an IExtentService instead - something like public interface IExtentService { IEnumerable AllInstances(ISession session); } The *only* reason I have this is so that when I am writing tests and need data from the DB I can instead mock the IExtentService and return an in-memory Li

[nhusers] Re: Using Same component in same Entity with Mapping.Attributes problem

2009-06-18 Thread Fethi Gürcan
Hello, Nobody answered me. So i changed my copy of mapping.attributes sources with a simple rule. ( Changed method: NHibernate.Mapping.Attributes.HbmWriter.WriteComponent(System.Xml.XmlWriter writer, System.Type type)) Rule: property.column of a component = component.name+property.column So

[nhusers] How to Add Alias to Indexed Collection and adding sequence key to intermediate joining table

2009-06-18 Thread raj
I have many to many Mapping between Company table to Contact table using Company_Contact_role table Company_Contact_role Table has Company_Contact_role_Id, CompanyId,ContactId,Contact_type_Code Here is my mapping The mapping work great as i expected. But

[nhusers] Re: Mapping composed primary keys and foreign keys

2009-06-18 Thread Caio Kinzel Filho
the logic is in the existing application, and not in anyway acessible to my application. so in this way I would have to write all logic to store the data in the db, which is what I'm trying to avoid with the orm in the first place... On Thu, Jun 18, 2009 at 9:52 AM, Fabio Maulo wrote: > DB is a d

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Fabio Maulo
Right Skafa. I saw a lot IReposity that are really IDao ...but you know... IReposity has another fashion meaning ;) 2009/6/18 Skafa > > If you use a 'repository' to abstract away your persistence > technology, it really is a Data Access Object. > > The definition of a repository is: 'Mediates be

[nhusers] Re: Mapping composed primary keys and foreign keys

2009-06-18 Thread Fabio Maulo
DB is a data-repository and nothing more. In general before save data you need some logic so...if the logic is all in the DB (SPs, triggers for *any kind* of operation) you can access directly to the DB. if the logic is in the application, 2 applications should use a common logic in a application-s

[nhusers] How to Alias Index Collection ,Adding Sequence Key on a Many to Many Relation ship

2009-06-18 Thread raj
In my application i have many to many relation ship between Company to Contacts. Company and Contact joined by Company_Contact_Role table. It holds CompanyId,ContactId and Contact_role ( primay, sales,etc...). Here is my relation The above mapping works pe

[nhusers] Re: Mapping composed primary keys and foreign keys

2009-06-18 Thread Caio Kinzel Filho
>“I can’t change the DB because there are other applications using it”… my >friend in this case the first step should be write a good service layer to >serve “externals” applications. Well, this is actually the case, the app i'm creating will not replace, but wok in parallel with the existing o

[nhusers] Re: how to set update cascade for many-to-one's child objects ?

2009-06-18 Thread Vels
thank you so much fabio.. will check. -vels- On Jun 17, 11:01 pm, Fabio Maulo wrote: > Ah sorry you said win&wpf...Then I think you should try CpBT > A summary > posthttp://fabiomaulo.blogspot.com/2009/01/aspect-conversation-per.html > >

[nhusers] Re: Insert Statement

2009-06-18 Thread Fabio Maulo
Update your app at leat to NH2.0.1, there you can use ISqlQuery.ExecuteUpdate() 2009/6/18 topherdel > > How do I execute an insert statement using NH v1.2.1? > > From what I am seeing, HQL, IQuery, SqlQuery are all select queries. > I created a SqlCommand and assigned it the nhibernate session's

[nhusers] Re: Template Class Mapping in ClassName.hbm.xml file

2009-06-18 Thread Fabio Maulo
Yes http://fabiomaulo.blogspot.com/2008/10/entity-name-in-action-strongly-typed.html That is something old... the difference is that now you don't need to specify the entity name in Save, Update and so on. 2009/6/18

[nhusers] Re: Mapping composed primary keys and foreign keys

2009-06-18 Thread Fabio Maulo
legacy DB in a new application. I must admit I'm not an expert using NH with composite-Id http://fabiomaulo.blogspot.com/2009/06/database-eliot-ness-of-it.html 2009/6/17 Caio Kinzel Filho > > unfortunately, yes > > On Wed, Jun 17, 2009 at 8:24 PM, Fabio Maulo wrote: > > legacy db, right ? > > >

[nhusers] Template Class Mapping in ClassName.hbm.xml file

2009-06-18 Thread TheTraveler
Dear Friends, I wrote a simple template class and would like to persist it to the DB. Does anybody know how to map it in the hbm.xml file ? Thank, Ore. ~ Code: public class MyClass { private string _myString; public virtual MyString { get; set; } } --~--~-~--~~

[nhusers] NHibernate.TransactionException: Transaction not connected, or was disconnected

2009-06-18 Thread Carsten Hess
Hello NHUsers, Is anyone getting this exception ? The code shows that it is when the underlying ADO.NET transaction is not null, but its contained Connection is. I get it at random times, and its the only exception I get - no "connection closed by peer" exception or anything. at NHibernate.Tran

[nhusers] Finding out which classes are cached

2009-06-18 Thread Tolomaüs
Hi, Is there a way to find out in code which classes are cached (i.e. have the in their mapping)? I tried the IClassMetadata but it doesn't seem to expose this info. The EntityPersister has a HasCache property but I have to pass it an instance of an entity. The scenario for which I need this i

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Tuna Toksoz
(yes I believe i lost the meaning, i should keep reading DDD books from where i left.) 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, Jun 18, 2009 at 10:40 AM, Skafa wrote: > > If you use a

[nhusers] Re: LINQ2NH and the Repository Pattern

2009-06-18 Thread Skafa
If you use a 'repository' to abstract away your persistence technology, it really is a Data Access Object. The definition of a repository is: 'Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.' (fowler) note the 'collection-like'.

[nhusers] Configuration Question

2009-06-18 Thread Maik
Hi folks, I have a question about how to configure a DLL using nhibernate. Of course the dll will not be the only object using nhibernate. Probably the application using this assembly will also use another database access via nhibernate. So I ran into a specific problem. How should I tell my own