[nhusers] Re: Mapping vs Query Dilemma

2010-02-17 Thread Sal
Sure, I am open to anything at this point. Are you talking about a one to one relationship with a hand rolled sql query? Could you point me to something similar to what you are describing? Thanks. On Feb 16, 10:28 pm, Fabio Maulo fabioma...@gmail.com wrote: 2010/2/17 Fabio Maulo

[nhusers] HQL - left join on opposite direction

2010-02-17 Thread Dor Rotman
Hello, All the documentation I see regarding HQL left joins work this way: from Eg.Cat as cat left join cat.Kittens as kitten What if the mapping between cat and kitten doesn't exist, but there is a mapping between kitten and cat? I'd like to run this query: from Eg.Cat as cat left join

[nhusers] Compilation of Queries

2010-02-17 Thread Ricardo Peres
Hello, Does NHibernate support compilation of queries (HQL, Criteria, LINQ)? I was looking for ways to speed up the generation of the actual SQL, I assume it has to be done each time a query is List()ed, or is there a query cache for HQL, Criteria and LINQ? Thanks! Ricardo Peres -- You

Re: [nhusers] Re: Mapping vs Query Dilemma

2010-02-17 Thread Jason Dentler
Hi Sal, This sounds like temporal objects pattern. Check out Envers. Unfortunately, it's Hibernate only (java) and as far as I know, we don't have a working equivalent in .NET. Thanks, Jason On Wed, Feb 17, 2010 at 5:29 AM, Sal salbass...@hotmail.com wrote: Sure, I am open to anything at this

[nhusers] Re: totally confused about transactions and session flush

2010-02-17 Thread ajaishankar
Thanks Lothan! NH examples code I think follow this pattern: using( var session = sessionFactory.CreateSession() ) using( var tx = session.BeginTransaction() ) { var entity = new { Name = John }; session.Save(entity) session.Flush() } Behavior

[nhusers] Re: Collection was not processed by flush()

2010-02-17 Thread allan.ritc...@gmail.com
Easy fix. When configuring your session factory, replace the default auto flush event listeners with the classes below. [Serializable] public class FlushFixEventListener : DefaultFlushEventListener { public override void OnFlush(FlushEvent @event) { try {

Re: [nhusers] Compilation of Queries

2010-02-17 Thread Gustavo Ringel
HQL named queries are compiled at the beggining. Gustavo. On Wed, Feb 17, 2010 at 2:50 PM, Ricardo Peres rjpe...@gmail.com wrote: Hello, Does NHibernate support compilation of queries (HQL, Criteria, LINQ)? I was looking for ways to speed up the generation of the actual SQL, I assume it

[nhusers] Re: totally confused about transactions and session flush

2010-02-17 Thread Jason Meckley
I tend to treat an NH transaction as a DB transaction, but I'm not 100% sure about this. I know there are hooks in the NH transaction that are connected to the 2nd level cache. i'm not sure what else is connected to the NH transaction. As of 1.2 a transaction is required for NH to persist

[nhusers] Re: Compilation of Queries

2010-02-17 Thread Ricardo Peres
Hi, Gustavo! I didn't mean named queries, but those created with CreateQuery(String queryString). On a side note, if named queries are compiled at the beginning, it means that we cannot have multiple queries, for different DB engines, because some of them will not compile, is that so? Thanks,

[nhusers] Write only property for legacy database

2010-02-17 Thread Alex McMahon
I have a legacy database that I'm restricted from changing. I have 2 related tables that both have a foreign key to the same 3rd table. In my application I'd rather not have this relationship repeated on both classes. But when I don't map this relationship for both classes I get problems as

Re: [nhusers] Re: Compilation of Queries

2010-02-17 Thread Gustavo Ringel
The compilation is done per session factory so i don't see any problem. I don't think NH saves the conversion to SQL for any other query. HQL is easily done at the beginning during BuildSessionFactory(). Gustavo. On Wed, Feb 17, 2010 at 4:26 PM, Ricardo Peres rjpe...@gmail.com wrote: Hi,

Re: [nhusers] Re: Compilation of Queries

2010-02-17 Thread Fabio Maulo
Instead session.CreateQuery you can write session.GetNamedQuery a named query can be an HQL or a SQL or a H-SQL All queries wrote in the mapping are checked and compiled at BuildSessionFactory Dynamic queries as Criteria and QueryOver are dynamically created an so interpreted/translated each

Re: [nhusers] Re: totally confused about transactions and session flush

2010-02-17 Thread Robert Rudduck
This link might help out w/r/t Transactions and the Second Level Cache: http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/11/09/first-and-second-level-caching-in-nhibernate.aspx On Wed, Feb 17, 2010 at 7:58 AM, Jason Meckley jasonmeck...@gmail.comwrote: I tend to treat an NH

Re: [nhusers] Write only property for legacy database

2010-02-17 Thread Robert Rudduck
NHibernate doesn't care about visibility so you could use internl / private / protected properties or just use fields. All of which can be hidden from external classes and the reference exsits to keep NH happy. On Wed, Feb 17, 2010 at 8:33 AM, Alex McMahon fluxmu...@gmail.com wrote: I have a

Re: [nhusers] Write only property for legacy database

2010-02-17 Thread Fabio Maulo
Have you an idea about from where NH can know/read to write in the FK ? 2010/2/17 Alex McMahon fluxmu...@gmail.com I have a legacy database that I'm restricted from changing. I have 2 related tables that both have a foreign key to the same 3rd table. In my application I'd rather not have this

[nhusers] Re: Write only property for legacy database

2010-02-17 Thread Alex McMahon
Robert, Thanks, yes this is one solution I've arrived at, I've got a protected property that I map for NH that is just a getter. ClassB: ClassA A; protected virtual long ClassCId{ get{ return A.ClassC.Id }set{ } } I just thought I'd see if there was a better way someone could suggest On Feb

[nhusers] Re: Write only property for legacy database

2010-02-17 Thread Alex McMahon
Fabio, Thanks for your reply... I don't quite understand what you mean... I think you're saying how can NH know that it needs to put something in the DB if you don't tell it to. I see what you're saying (particularly as it's not just a default canned value that needs to go in). I guess what I

[nhusers] it's possible to use setFirstResult in hql or Eq(MyAbstractProperty.class, ...) in icriteria?

2010-02-17 Thread kor
i all, i have a query where i need to filter the returned items using SetFirstResult/SetMaxResult. In this query i need to use the special property .class (in hql is ... where p.MyAbstractProperty.class = . At the moment i didn't find a way to use the setFirst/MAx results with hql or to get

[nhusers] Many to many with extra system columns(Lastupdateduser,timestamp etc..)

2010-02-17 Thread sravan
I have the following three tables. ModelMemo is a joiner table Model ModelId Name CreateUserId CreateTimestamp LastupdatedUserId LastupdatedTimestamp Memo MemoId Name CreateUserId CreateTimestamp LastupdatedUserId

Re: [nhusers] it's possible to use setFirstResult in hql or Eq(MyAbstractProperty.class, ...) in icriteria?

2010-02-17 Thread Robert Rudduck
IQuery q = session.CreateQuery(hql); q.SetMaxResults(10).SetFirstResult(10); IIRC, NH 2.1 or newer should use the .class property in HQL. On Wed, Feb 17, 2010 at 10:44 AM, kor korkl...@yahoo.it wrote: i all, i have a query where i need to filter the returned items using

[nhusers] CriteriaTransformer.TransformToRowCount doesnt work with Aggregate Queries

2010-02-17 Thread Scott White
Using version 2.1.0.4 Since the following code clears the projection before adding the rowcount as a projection if the target query had Group By clauses these will be lost and affect the count returned. The rowcount will be much higher than expected: public static ICriteria

[nhusers] How to get an entity/mapping + relation tree?

2010-02-17 Thread mynkow
Hi, I have many entities/mappings with 1:n, n:1 and n:m. How can I get all classes related to User entity for example and go deeper until the whole relation graph is built. In other words I want to get the relation graph of the mappings. Thank you. -- You received this message because you are

Re: [nhusers] HQL - left join on opposite direction

2010-02-17 Thread Diego Mijelshon
I'm afraid it's not possible. But if you have the use case, why not create the mapping on Cat? It's easier if you don't go against the tool :-) Diego On Wed, Feb 17, 2010 at 08:48, Dor Rotman shumbat...@gmail.com wrote: Hello, All the documentation I see regarding HQL left joins work this

[nhusers] ReadUncommitted broken in SqlLite against NHibernate

2010-02-17 Thread Pat
I am using sqllite for test cases in a project that leverages NHibernate. Everything is working great, except when I try to create a ReadUncommitted transaction: e.g. Session.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted) The error message is: isolationLevel (thats it) The call

Re: [nhusers] Re: Write only property for legacy database

2010-02-17 Thread Diego Mijelshon
access=readonly Diego On Wed, Feb 17, 2010 at 12:50, Alex McMahon fluxmu...@gmail.com wrote: Fabio, Thanks for your reply... I don't quite understand what you mean... I think you're saying how can NH know that it needs to put something in the DB if you don't tell it to. I see what

Re: [nhusers] HQL - left join on opposite direction

2010-02-17 Thread Fabio Maulo
http://fabiomaulo.blogspot.com/2009/05/nhibernate-210-hql-with-clause.html http://fabiomaulo.blogspot.com/2009/05/nhibernate-210-hql-with-clause.htmlor, leaving the class unchanged you can map the collection of Kittens with access=none and then use it in HQL 2010/2/17 Dor Rotman

Re: [nhusers] Many to many with extra system columns(Lastupdateduser,timestamp etc..)

2010-02-17 Thread Diego Mijelshon
Custom sql-insert might work. However, it's probably better to create the ModelMemo entity and project it in your model. Example: class Model { public IEnumerableMemo Memos { get{ return ModelMemos.Select(mm = mm.Model); } } public void Add(Memo memo) { ModelMemos.Add(new

Re: [nhusers] Re: Write only property for legacy database

2010-02-17 Thread Fabio Maulo
access=readonly 2010/2/17 Alex McMahon fluxmu...@gmail.com Fabio, Thanks for your reply... I don't quite understand what you mean... I think you're saying how can NH know that it needs to put something in the DB if you don't tell it to. I see what you're saying (particularly as it's not

[nhusers] NHibernate.Linq select bug

2010-02-17 Thread Rikard Pavelic
I stumbled upon this bug while trying to use NHibernate.Linq [Test] public void SelectWithWrapping() { var list = (from user in session.LinqUser() select new Wrapper(user, xxx)).ToList(); Assert.AreEqual(3, list.Count); } public class Wrapper { public Wrapper(User

[nhusers] Update on parent object cause an insert on child objects

2010-02-17 Thread MiloszeS
Hi all, I have two classes: Parent(1) and (*)Child. I've spotted a weird situation. When I fetch a Parent object (with a Child collection) using UniqueResultParent and after that Update a Parent (I didn't made any modifications on Parent nor any Child objects) nhibernate inserts a new copy of

[nhusers] Mapping enum 0 to null in database

2010-02-17 Thread Peter4922
Hi, I have a table with requests and a corresponding request class. A request has a property called Type which is a C# enumeration. Possible types are NONE=0, TRICKLEFEED=1, etc. When the type is NONE the value 0 is stored in the database. For TRICKLEFEED 1 is stored in the DB. How can I setup

[nhusers] Re: it's possible to use setFirstResult in hql or Eq(MyAbstractProperty.class, ...) in icriteria?

2010-02-17 Thread kor
sorry, found the stupid solution :) setmaxresult on the iquery object and not inside the hql. -- You received this message because you are subscribed to the Google Groups nhusers group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to

[nhusers] Schema Management Tool

2010-02-17 Thread newman.de
Hi all, Allow me to preface this by saying I don't do much Open Source development so please excuse me if this is not the correct place for this discussion, or if I am reinventing the wheel. As many of you know, NHibernate provides a simple API for Creating, Updating, and Dropping a schema that

Re: [nhusers] How to get an entity/mapping + relation tree?

2010-02-17 Thread nadav s
if i understand correctly, you wanna fetch one or more user, and would like everything to be fetched with it you can set all the associations to lazy=false either ithrough the mappings file or when you fetch the object (with FetchMode=join). if you're records are big, i think its better to use

[nhusers] Re: Best practice to iterate a collection event's Collection?

2010-02-17 Thread Jason Hanford-Smith
Have you looked at the source (SVN) to see how Entries is used? BasicCollectionPersister and OneToManyPersister use Entries in their DoUpdateRows methods. Maybe you need to look at your need from another direction. On Feb 5, 11:39 am, Michael diSibio michael.disi...@gmail.com wrote: The

Re: [nhusers] Schema Management Tool

2010-02-17 Thread Paulo Quicoli
Hi Dave, for me it's very cool and needed. Just as you, I also make update schemas in a NUnit test, that is what we have at moment. But now, your tool introduces a good alternative. I agree, a command line tool is necessary, and also, a GUI tool would be nice. Thanks for your time and work

Re: [nhusers] Should I use int or System.Int32??

2010-02-17 Thread Fabio Maulo
which is the difference in .NET ? 2010/2/17 haarrrgh haarr...@googlemail.com When I write classes and mappings that contain Integer values, what data types should I use? short, int and long? Or System.Int16, System.Int32 and System.Int64 ? Does it make any difference which of these

Re: [nhusers] Should I use int or System.Int32??

2010-02-17 Thread Craig van Nieuwkerk
No difference really. http://stackoverflow.com/questions/62503/c-int-or-int32-should-i-care Craig On Wed, Feb 17, 2010 at 11:41 PM, haarrrgh haarr...@googlemail.com wrote: When I write classes and mappings that contain Integer values, what data types should I use? short, int and long? Or

Re: [nhusers] Schema Management Tool

2010-02-17 Thread Fabio Maulo
only a note.. To add a dll or to add multiple dll you can use the hibernate.cfg.xml only. 2010/2/17 newman.de newman...@gmail.com Hi all, Allow me to preface this by saying I don't do much Open Source development so please excuse me if this is not the correct place for this discussion, or

Re: [nhusers] Mapping enum 0 to null in database

2010-02-17 Thread Fabio Maulo
IUserType if you have time to implements it otherwise just keep 0 and 1 since MyEnum is different than MyEnum? I would know who said that 0 = null. 2010/2/17 Peter4922 peter4...@googlemail.com Hi, I have a table with requests and a corresponding request class. A request has a property

Re: [nhusers] Update on parent object cause an insert on child objects

2010-02-17 Thread Fabio Maulo
http://nhforge.org/doc/nh/en/index.html#manipulatingdata-graphs If a transient child is dereferenced by a persistent parent, nothing special happens (the application should explicitly delete the child if necessary) unless cascade=all-delete-orphan, in which case the orphaned child is deleted. In

[nhusers] Using guid.comb to create sequential IDs in distributed environment

2010-02-17 Thread Chris J
I am evaluating using NHibernate as the ORM for our platform. In our environment, there are multiple servers performing operations on the database. I'd like to be able to use sequential IDs when adding new records to certain tables. I have read about and experimented with the 'guid.comb' ID