[nhusers] Re: Composite-element with null columns in map is ignored

2009-07-01 Thread ernestmartin

Hi Fabio.

Thank you for responding so quickly.

The truth is that what you say makes sense, but then I guess that
Hibernate should take note that if all properties are null the
corresponding record in the database should not exist. The problem is
that the record is always created, even when the properties contain
null values. Therefore when you try to remove the entity an error
ocurs because there is a relationship in the database.

I'll try to do something with what you said.

Thank you very much!


On 1 jul, 20:04, Fabio Maulo  wrote:
> I don't think somebody should "fix" that issue (more... somebody should
> close it as "won't fix").A component with all properties null is nothing
> (mean is null it self).
> There is another possibility... a component is always created even when all
> properties are null (this is not the way NH is working).
> As usual you can override the NH default behaviour (we can't cover all
> taste) using a custom  for your component.
>
> 2009/7/1 ernestmartin 
>
>
>
>
>
>
>
> > Hello everyone.
>
> > I'm trying make an entity containing a dictionary with their texts in
> > several languages. To do this I created the product class that
> > contains this simple properties:
>
> > 
> > public virtual string Name { get; set; }
> > public virtual IDictionary CultureTexts
> > {
> >  get { return cultureTexts; }
> >  protected set { cultureTexts = value; }
> > }
> > private IDictionary cultureTexts = new
> > Dictionary();
> > 
>
> > and a CultureText class that contains this:
>
> > 
> > public virtual string Description { get; set; }
> > public virtual string OtherDetails { get; set; }
> > 
>
> > The mapping is as follows:
>
> >  
> >    
> >      
> >        Product_Sequence
> >      
> >    
> >    
> >    
> >      
> >      
> >      
> >        
> >        
> >      
> >    
> >  
>
> > The problem is that when the texts are null (both properties)
> > collection is not loaded and errors begin to occur.
>
> > I found this bug in Hibernate:
> >http://opensource.atlassian.com/projects/hibernate/browse/HHH-3836
>
> > There seems to be the same problem with NHibernate.
>
> > Someone can help me with this problem? (some workaround)
>
> > Thanks in advance
>
> --
> 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: Legacy Model & One-to-many Mapping

2009-07-01 Thread Oskar Berggren

Your Parent table looks exactly like a regular relation table from a
many-to-many relationship. Someone should be shot! :)

Can you introduce a view in the database perhaps called "RealParent"
which shows the result of "SELECT DISTINCT ParentName FROM Parent"?
Then maybe you can map your Parent class to this view, and in the
mapping treat the Parent table as the relation table it is.

Hmm... maybe this will cause problems when inserting/updating...

Otherwise perhaps you will have to work around this in your domain
model, if no one can come up with another solution.

/Oskar


2009/6/30 Sergey Shishkin :
>
> Hi,
>
> I have a rather ugly legacy data model to map.
>
> The entity model should look like this:
>
> public class Parent
> {
>    public string Name {get;set;};
>    public virtual ICollection {get;set;}
> }
>
> public class Child
> {
>    public string SomeProp {get;set;}
>    ...
> }
>
> And the legacy data model looks like this:
>
> Parent
> (
>    PK ParentName nvarchar(10),
>    PK FK ChildId uniqueidentifier
> )
>
> Child
> (
>    PK ChildId uniqueidentifier,
>    SomeProp nvarchar(50),
>    ...
> )
>
> And here is my mapping:
>
>  assembly="IntegrationTests, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=null" namespace="IntegrationTests.Domain">
>  
>    
>      
>    
>  
> 
>
> The problem here is that when I query for Parents, I get duplicates,
> because table Parent has multiple rows per Parent entity (one per
> Child entity). I don't make composite-id because from the domain
> perspective Parent's Name distinguishes entities unambiguously.
>
> Is there any way in NH to map it 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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread jobsamuel

I thought that since you are using db generated identity, your save
would result in a db call and your further call to criteria query
would work. Even if you are not using db generated id the session
would automatically flush upon a query and your criteria query should
still work. I think this is mentioned in the document that in flush
mode auto firing a query happens to be a flush point.
Is my understanding wrong, if it correct then your criteria query
should have worked, what is the reason for it to fail?
--~--~-~--~~~---~--~~
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: Interception the sql

2009-07-01 Thread Dario Quintana
You can use Log4net to see what SQL is sent to the DB
http://www.davesquared.net/2008/01/viewing-sql-generated-by-nhibernate.html

On Wed, Jul 1, 2009 at 9:39 PM, Bruno Lima  wrote:

> Hello.
>
>  Is there way to intercepting the sql that is sending to data base?
>
> I want to do like the EmptyInterceptor does with the Entities.
>
> Sorry,  but I´m a newbie.
>
> Thank you.
>
> Bruno.
>
>
>
> >
>


-- 
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: Interception the sql

2009-07-01 Thread Fabio Maulo
Sorry Bruno.Try to explain what you need without talk about the solution
that you think had found.

2009/7/2 Fabio Maulo 

> What?
>
> 2009/7/1 Bruno Lima 
>
> Hello.
>>
>>  Is there way to intercepting the sql that is sending to data base?
>>
>> I want to do like the EmptyInterceptor does with the Entities.
>>
>> Sorry,  but I´m a newbie.
>>
>> Thank you.
>>
>> Bruno.
>>
>>
>>
>> >>
>>
>
>
> --
> 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: Interception the sql

2009-07-01 Thread Fabio Maulo
What?

2009/7/1 Bruno Lima 

> Hello.
>
>  Is there way to intercepting the sql that is sending to data base?
>
> I want to do like the EmptyInterceptor does with the Entities.
>
> Sorry,  but I´m a newbie.
>
> Thank you.
>
> Bruno.
>
>
>
> >
>


-- 
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: Propery Formula

2009-07-01 Thread Fabio Maulo
A SP in a  really is something very new for me.Btw in NH2.0.1 you
must register the KeyWord 'EXEC' in your dialect.
in NH2.1.0 the keyword should be there.

2009/7/1 Pete 

>
> Does anyone know if mapping a property to a stored procedure should
> work?
>
> 
>
> 
>  formula="( EXEC MyStoredProc MyId )" />
>
> The generated SQL is something like:
>
> SELECT
> this_.MyId as 
> this_.EXEC this_.MyStoredProc this_.MyId as formula_0
> FROM MyTable this_
>
> where i am trying to get:
>
> SELECT
> this_.MyId as 
> EXEC MyStoredProc this_.MyId as formula_0
> FROM MyTable this_
>
> I am trying to create a boolean readonly property that is populated by
> a IF EXISTS (SELECT ... ) query to see if there are rows related to
> this table in another table.
>
>
> >
>


-- 
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: Propery Formula

2009-07-01 Thread Fabio Maulo
2009/7/1 Pete 

>
> I am trying to create a boolean readonly property that is populated by
> a IF EXISTS (SELECT ... ) query to see if there are rows related to
> this table in another table.
>

Don't say it to your DBA, preserve his health (an infarct is the minimum
when he will see the result of a massive select over that entity).

-- 
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: Property with Oracle´s sequence?

2009-07-01 Thread Bruno Lima
Thank you Michael for help me.

It´s works fine!

Better if exists a automatic way to do that on mapping my property. :)

About the index column, is only for sorting asc or dec, but respecting the
sequence returned values.

Thank you again.

Bruno.
2009/7/1 mhanney 

>
>
> You could map it as an int and set the value explicitly using a sql
> query.
>
> property = (int)session.CreateSQLQuery("SELECT YOUR_SEQUENCE.NEXTVAL
> FROM DUAL").AddScalar("NEXTVAL", NHibernateUtil.Int32).UniqueResult
> ());
>
> .. and be sure to use transactions.
>
> If you don't want Oracle specific SQL in your C#, put the sql in your
> mapping
>
> 
>  
>SELECT YOUR_SEQUENCE.NEXTVAL FROM DUAL
> 
>
> Then call it with:
>
> property = (int)session.GetNamedQuery("SequenceNextValue").UniqueResult
> ();
>
> What is the purpose of your 'index' column? You might want to look the
> Version column instead.
>
> http://nhforge.org/blogs/nhibernate/archive/2009/04/15/nhibernate-mapping-concurrency.aspx
>
> c
>
>
> On Jul 1, 10:37 am, brulimat  wrote:
> >  Hi guys!
> >
> >  I have a question.
> >
> >  My IDs are GUID but a specific property is an index column.
> >  This column uses Oracle´s Sequence.
> >  My question is: How to use a Oracle`s Sequence into a property?
> >
> >  Sorry, but I´m a newbie.
> >
> >  Thank you.
> >
> >  Bruno.
> >
>

--~--~-~--~~~---~--~~
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: Property with Oracle´s sequence?

2009-07-01 Thread mhanney


You could map it as an int and set the value explicitly using a sql
query.

property = (int)session.CreateSQLQuery("SELECT YOUR_SEQUENCE.NEXTVAL
FROM DUAL").AddScalar("NEXTVAL", NHibernateUtil.Int32).UniqueResult
());

.. and be sure to use transactions.

If you don't want Oracle specific SQL in your C#, put the sql in your
mapping


  
SELECT YOUR_SEQUENCE.NEXTVAL FROM DUAL


Then call it with:

property = (int)session.GetNamedQuery("SequenceNextValue").UniqueResult
();

What is the purpose of your 'index' column? You might want to look the
Version column instead.
http://nhforge.org/blogs/nhibernate/archive/2009/04/15/nhibernate-mapping-concurrency.aspx

Michael.


On Jul 1, 10:37 am, brulimat  wrote:
>  Hi guys!
>
>  I have a question.
>
>  My IDs are GUID but a specific property is an index column.
>  This column uses Oracle´s Sequence.
>  My question is: How to use a Oracle`s Sequence into a property?
>
>  Sorry, but I´m a newbie.
>
>  Thank you.
>
>  Bruno.
--~--~-~--~~~---~--~~
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: Paging error: The column xxx was specified multiple times for query

2009-07-01 Thread Dave

SOLVED:

I fixed my own issue the problem was I had different case in my  HBM
file to a property  upper-case in the property but lower case when it
was used in a relationship

On Jul 1, 4:30 pm, Dave  wrote:
> I have made a Generic class that adds paging and criteria.
>
> When I call
>
> criteria.SetMaxResults(limit.Value).SetFirstResult(start.Value);
>
> I get the error "The column xxx was specified multiple times for
> query"
> Is this bug in nHibernate v2.0.1 ? or my own bug?
>
> I had similar code using a DetachedCriteria and calling it manually
> and it worked.
>
> Cheers
> Dave
--~--~-~--~~~---~--~~
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] Propery Formula

2009-07-01 Thread Pete

Does anyone know if mapping a property to a stored procedure should
work?






The generated SQL is something like:

SELECT
this_.MyId as 
this_.EXEC this_.MyStoredProc this_.MyId as formula_0
FROM MyTable this_

where i am trying to get:

SELECT
this_.MyId as 
EXEC MyStoredProc this_.MyId as formula_0
FROM MyTable this_

I am trying to create a boolean readonly property that is populated by
a IF EXISTS (SELECT ... ) query to see if there are rows related to
this table in another table.


--~--~-~--~~~---~--~~
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] Interception the sql

2009-07-01 Thread Bruno Lima
Hello.

 Is there way to intercepting the sql that is sending to data base?

I want to do like the EmptyInterceptor does with the Entities.

Sorry,  but I´m a newbie.

Thank you.

Bruno.

--~--~-~--~~~---~--~~
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Fabio Maulo
2009/7/1 Graham Bunce 

>
> >You can even explain the "logic" to NH using  ;)
>
> Sheesh, I've just about got my head around NH 2.0.1GA without getting
> my head around all the new 2.1.0 features!!


Stay updated... stay updated the world of Open Source is going fast. ;)
-- 
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Graham Bunce

>You can even explain the "logic" to NH using  ;)

Sheesh, I've just about got my head around NH 2.0.1GA without getting
my head around all the new 2.1.0 features!!


--~--~-~--~~~---~--~~
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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Graham Bunce

Ah. Far too subtle for me :)

On Jul 2, 12:02 am, Fabio Maulo  wrote:
> 2009/7/1 Graham Bunce 
>
>
>
> > Sorry Fabio, what that JIRA link meant to help me? ;)
>
> Was a joke. Apparently the limits of sub-levels is 450.
>
> --
> 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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Fabio Maulo
2009/7/1 Graham Bunce 

>
> Sorry Fabio, what that JIRA link meant to help me? ;)
>

Was a joke. Apparently the limits of sub-levels is 450.

-- 
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Fabio Maulo
2009/7/1 Graham Bunce 

>
> And to explain your issue, NH always goes to the DB for a query. I
> suspect this is for performance reasons as how can it search its cache
> on any number of unknown (by the NH designer) parameters that a
> developer will provide? It would just be too slow. Therefore it will
> ONLY go to the cache where you provide an ID via a non-criteria call
> (e.g. Load). It's the only way that I can see it performing. Also, who
> is to say that an object you search on by (e.g. name) is the same
> object as you added to the cache previously. You may *know* its the
> same because you understand the logic, but NH does not. Therefore it
> needs to go to the DB to ensure it has the latest view of the DB world
> - which ultimately is what NH is all about.


You can even explain the "logic" to NH using  ;)

-- 
Fabio Maulo
I prefer to try something good and fail, than to try something wrong and
achieve 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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Tuna Toksoz
that user wanted to cascade infinitely many levels of children. it was a bit
off topic, i believe.

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, Jul 2, 2009 at 1:44 AM, Graham Bunce wrote:

>
> Yes, application logic states its only 3 levels and I only need to do
> this for a query. I'm not getting any fails, I'm just wondering if I
> can do what I want with HQL or criteria. If not, I can drop down to
> code but I'd rather keep it in the DB.
>
> I guess I could turn Lazy Load off for the whole aggregate but its a
> little tricky to do that due to the architecture design. Is there
> anyway to overwrite a  mapping statement that exists in a base
> class by an inheriting mapping file?
>
> Sorry Fabio, what that JIRA link meant to help me? ;)
> >
>

--~--~-~--~~~---~--~~
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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Graham Bunce

Yes, application logic states its only 3 levels and I only need to do
this for a query. I'm not getting any fails, I'm just wondering if I
can do what I want with HQL or criteria. If not, I can drop down to
code but I'd rather keep it in the DB.

I guess I could turn Lazy Load off for the whole aggregate but its a
little tricky to do that due to the architecture design. Is there
anyway to overwrite a  mapping statement that exists in a base
class by an inheriting mapping file?

Sorry Fabio, what that JIRA link meant to help me? ;)
--~--~-~--~~~---~--~~
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Graham Bunce

Understandable but many of the issues you get with NH (using
Identities generated by a DB for example) you can run into with other
ORM's or ORM-like products such as Linq-SQL. Fabio (quite
understandably) has a thing against DB identity and will usually be
quite aggressive against it and not always explain himself fully for
someone struggling with new concepts. He has an awful lot to do though
and English isn't his first language so we're patient with him :)

NH is a big learning curve IMO but when you finally get your head
around it, it's usually worth it. Maybe consider it for your next
project taking into account what you have learnt from this one. One of
the things you quickly do is to dump DB identity and use HiLo or GUID
COMB - i.e. let NH generate your keys for you.

And to explain your issue, NH always goes to the DB for a query. I
suspect this is for performance reasons as how can it search its cache
on any number of unknown (by the NH designer) parameters that a
developer will provide? It would just be too slow. Therefore it will
ONLY go to the cache where you provide an ID via a non-criteria call
(e.g. Load). It's the only way that I can see it performing. Also, who
is to say that an object you search on by (e.g. name) is the same
object as you added to the cache previously. You may *know* its the
same because you understand the logic, but NH does not. Therefore it
needs to go to the DB to ensure it has the latest view of the DB world
- which ultimately is what NH is all about.

I'm a little hazy as its been a while since I used DB identity with NH
but I think that in your case, you will not get an ID on the save as
you have told NH to get the key from the DB. As you have worked out, a
save does not save to the DB but saves to the cache (to be precise,
adds it to the current Unit of Work). NH will only get the ID when you
Flush the cache (or alternatively I think it will also do it when you
Save within a transaction).

Can you flush after the save or something similar? If not then, tbh,
it sounds like you're not really using NH effectively and need to make
compromises as a result. Just like you'd have to to use Linq-SQL
(inherit from special classes) or ADO.NET (no in-built ORM mapping at
all).

Good luck.
--~--~-~--~~~---~--~~
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Josh Rogers
Ok, well I have spent the last 4 weeks trying to bend my application to work
with NHibernate and I can't lose anymore productivity so I am going to have
to pull out NHibernate and go back to dealing with ADO directly or find
another ORM solution.

I just wanted to thank everyone for their time, it was greatly appreciated
and I truly did learn a lot of new things.

Thank you,
Josh

On Wed, Jul 1, 2009 at 3:31 PM, Fabio Maulo  wrote:

> 2009/7/1 Josh Rogers 
>
>>
>> As far as the POID strategy I am using the db generated ID that increments
>> by 1 each time a new item is added.
>>
>
> If you mean identity you must know how identity work.
> Identity break the UnitOfWork pattern and session.Save mean a INSERT to DB.
> If you want work with conversation you must choose another POID strategy.
> http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html
>
> --
> 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: maybe slow performance

2009-07-01 Thread Jan Limpens
yip, that's the newest available build.

2009/7/1 Tuna Toksoz 

> Have you tried recent nhprof bit? Ayende has integrated this duration
> reporting into NH Core
>
> http://ayende.com/Blog/archive/2009/06/28/nh-prof-query-duration.aspx
>
>
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksoz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
>
>
>
>
> On Wed, Jul 1, 2009 at 11:01 PM, Jan Limpens wrote:
>
>> Hello,
>>
>> first of all - my doubt stems from the usage of nhprof and it's Duration
>> feature. I am not sure how much I can trust it, due to it's beta stage.
>>
>> When profiling my application, depending on their complexity the queries
>> shown in the profiler all have a duration from ~130ms to ~460ms, which is an
>> awful lot. If I run the very same queries in MSSQL Query Analyzer, I get a
>> spectrum between 1 and 30ms, which is much better of course.
>>
>> What could be causing this?
>>
>> My config is like that:
>>
>> >
>> type="Castle.Facilities.AutomaticTransactionManagement.TransactionFacility,
>> Castle.Facilities.AutomaticTransactionManagement" />
>> > isWeb="true"
>>
>> type="Castle.Facilities.NHibernateIntegration.NHibernateFacility,
>> Castle.Facilities.NHibernateIntegration"
>>
>> configurationBuilder="Fex.Data.FluentNHibernateConfigurationBuilder,
>> Fex.Data">
>> >  alias="nh.facility.default">
>> 
>> false
>> 1
>> > key="dialect">NHibernate.Dialect.MsSql2005Dialect
>> > key="connection.provider">NHibernate.Connection.DriverConnectionProvider
>> > key="connection.driver_class">NHibernate.Driver.SqlClientDriver
>> Data
>> Source=.\SQLEXPRESS;Initial Catalog=Fex;Integrated Security=True
>> ReadCommitted
>> Fex.dbo
>> true 1, false 0, yes
>> 'Y', no 'N'
>> 10
>> > key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
>> NHibernate.ByteCode.Castle
>> true
>> 
>> 
>>
>> I load the mappings during app_start within code.
>>
>> So either NhProf is wrong, or something else... I just have the feeling
>> that the app is slower than it ought to be. So this just might be the cause.
>> Anyone could help me a bit here?
>> --
>> Jan
>>
>>
>>
>
> >
>


-- 
Jan

--~--~-~--~~~---~--~~
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Fabio Maulo
2009/7/1 Josh Rogers 

>
> As far as the POID strategy I am using the db generated ID that increments
> by 1 each time a new item is added.


If you mean identity you must know how identity work.
Identity break the UnitOfWork pattern and session.Save mean a INSERT to DB.
If you want work with conversation you must choose another POID strategy.
http://fabiomaulo.blogspot.com/2008/12/identity-never-ending-story.html

-- 
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: maybe slow performance

2009-07-01 Thread Tuna Toksoz
Have you tried recent nhprof bit? Ayende has integrated this duration
reporting into NH Core

http://ayende.com/Blog/archive/2009/06/28/nh-prof-query-duration.aspx



Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Wed, Jul 1, 2009 at 11:01 PM, Jan Limpens  wrote:

> Hello,
>
> first of all - my doubt stems from the usage of nhprof and it's Duration
> feature. I am not sure how much I can trust it, due to it's beta stage.
>
> When profiling my application, depending on their complexity the queries
> shown in the profiler all have a duration from ~130ms to ~460ms, which is an
> awful lot. If I run the very same queries in MSSQL Query Analyzer, I get a
> spectrum between 1 and 30ms, which is much better of course.
>
> What could be causing this?
>
> My config is like that:
>
> 
> type="Castle.Facilities.AutomaticTransactionManagement.TransactionFacility,
> Castle.Facilities.AutomaticTransactionManagement" />
>  isWeb="true"
>
> type="Castle.Facilities.NHibernateIntegration.NHibernateFacility,
> Castle.Facilities.NHibernateIntegration"
>
> configurationBuilder="Fex.Data.FluentNHibernateConfigurationBuilder,
> Fex.Data">
>   alias="nh.facility.default">
> 
> false
> 1
>  key="dialect">NHibernate.Dialect.MsSql2005Dialect
>  key="connection.provider">NHibernate.Connection.DriverConnectionProvider
>  key="connection.driver_class">NHibernate.Driver.SqlClientDriver
> Data
> Source=.\SQLEXPRESS;Initial Catalog=Fex;Integrated Security=True
> ReadCommitted
> Fex.dbo
> true 1, false 0, yes
> 'Y', no 'N'
> 10
>  key="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,
> NHibernate.ByteCode.Castle
> true
> 
> 
>
> I load the mappings during app_start within code.
>
> So either NhProf is wrong, or something else... I just have the feeling
> that the app is slower than it ought to be. So this just might be the cause.
> Anyone could help me a bit here?
> --
> Jan
>
> >
>

--~--~-~--~~~---~--~~
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: How to run a custom SQL subquery?

2009-07-01 Thread Tuna Toksoz
You may want to implement your own "Projection" and use it with
Restrictions.In( ) thing.

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Wed, Jul 1, 2009 at 10:54 PM, Dietrich  wrote:

>
> want to fetch (with paging) records from a table where the ID is 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] maybe slow performance

2009-07-01 Thread Jan Limpens
Hello,

first of all - my doubt stems from the usage of nhprof and it's Duration
feature. I am not sure how much I can trust it, due to it's beta stage.

When profiling my application, depending on their complexity the queries
shown in the profiler all have a duration from ~130ms to ~460ms, which is an
awful lot. If I run the very same queries in MSSQL Query Analyzer, I get a
spectrum between 1 and 30ms, which is much better of course.

What could be causing this?

My config is like that:





false
1
NHibernate.Dialect.MsSql2005Dialect
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SqlClientDriver
Data
Source=.\SQLEXPRESS;Initial Catalog=Fex;Integrated Security=True
ReadCommitted
Fex.dbo
true 1, false 0, yes
'Y', no 'N'
10
NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle
true



I load the mappings during app_start within code.

So either NhProf is wrong, or something else... I just have the feeling that
the app is slower than it ought to be. So this just might be the cause.
Anyone could help me a bit here?
-- 
Jan

--~--~-~--~~~---~--~~
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] How to run a custom SQL subquery?

2009-07-01 Thread Dietrich

I've got a search function in my program that is able to build a sql
statement, which, when ran, will return a list of ID's (integers). I
want to fetch (with paging) records from a table where the ID is on
this list.

What is the best way to do this?

It seems like it would be nice and easy if NHibernate allow you to
manually specify a subquery's SQL for Subqueries.PropertyIn(), but it
doesn't, and there doesn't seem to be a way to wrap a sql string in a
detached criteria.

Any suggestions?


--~--~-~--~~~---~--~~
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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Josh Rogers
Ok, but how do I get it to look at the cache first?  I don't want it to
query the db until it can't find the object in cache, that would seem the
natural order of things.

As far as the POID strategy I am using the db generated ID that increments
by 1 each time a new item is added.


JOsh

On Wed, Jul 1, 2009 at 2:45 PM, Fabio Maulo  wrote:

> Query mean always "query-to-db", after the query to DB is executed the
> session-cache begin working returning you the existing instance in the
> session-cache or attaching new instance.Btw because you are talking about
> "conversation" we must know the POID strategy you are using.
>
> 2009/7/1 Josh Rogers 
>
> I don't know if cache is the right terminology, but it is the best I could
>> think of.
>>
>> I am adding an object to a conversation by calling
>> SessionFactory.GetCurrentSession().Save (which works), but later I need to
>> retrieve that object but I do not know the id  however I do know certain
>> attributes of the object. So I created an ICriteria to look for those
>> particular attributes, which works on its own for persisted objects.  Now my
>> problem is that when I have added the object to the cache but have not
>> flushed it and I later call the attribute search function it never finds the
>> object so it tries to create it again and then it crashes because it is
>> already there.  So the Save call sees the previously created entity as part
>> of the conversation even if it has not been persisted to the DB however the
>> CreateCriteria does notthis is not how I understood it to work, could
>> someone please clarify?
>>
>> Thanks,
>> Josh
>>
>>
>>
>
>
> --
> 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: Session Cache isn't working the way I thought it did.

2009-07-01 Thread Fabio Maulo
Query mean always "query-to-db", after the query to DB is executed the
session-cache begin working returning you the existing instance in the
session-cache or attaching new instance.Btw because you are talking about
"conversation" we must know the POID strategy you are using.

2009/7/1 Josh Rogers 

> I don't know if cache is the right terminology, but it is the best I could
> think of.
>
> I am adding an object to a conversation by calling
> SessionFactory.GetCurrentSession().Save (which works), but later I need to
> retrieve that object but I do not know the id  however I do know certain
> attributes of the object. So I created an ICriteria to look for those
> particular attributes, which works on its own for persisted objects.  Now my
> problem is that when I have added the object to the cache but have not
> flushed it and I later call the attribute search function it never finds the
> object so it tries to create it again and then it crashes because it is
> already there.  So the Save call sees the previously created entity as part
> of the conversation even if it has not been persisted to the DB however the
> CreateCriteria does notthis is not how I understood it to work, could
> someone please clarify?
>
> Thanks,
> Josh
>
> >
>


-- 
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] Session Cache isn't working the way I thought it did.

2009-07-01 Thread Josh Rogers
I don't know if cache is the right terminology, but it is the best I could
think of.

I am adding an object to a conversation by calling
SessionFactory.GetCurrentSession().Save (which works), but later I need to
retrieve that object but I do not know the id  however I do know certain
attributes of the object. So I created an ICriteria to look for those
particular attributes, which works on its own for persisted objects.  Now my
problem is that when I have added the object to the cache but have not
flushed it and I later call the attribute search function it never finds the
object so it tries to create it again and then it crashes because it is
already there.  So the Save call sees the previously created entity as part
of the conversation even if it has not been persisted to the DB however the
CreateCriteria does notthis is not how I understood it to work, could
someone please clarify?

Thanks,
Josh

--~--~-~--~~~---~--~~
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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Fabio Maulo
2009/7/1 Graham Bunce 

>
>  Can this do the recursive (max 3 levels) with sorting that
> I'm after?
>

Only three levels ?
http://nhjira.koah.net/browse/NH-1856

-- 
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: Composite-element with null columns in map is ignored

2009-07-01 Thread Fabio Maulo
I don't think somebody should "fix" that issue (more... somebody should
close it as "won't fix").A component with all properties null is nothing
(mean is null it self).
There is another possibility... a component is always created even when all
properties are null (this is not the way NH is working).
As usual you can override the NH default behaviour (we can't cover all
taste) using a custom  for your component.

2009/7/1 ernestmartin 

>
> Hello everyone.
>
> I'm trying make an entity containing a dictionary with their texts in
> several languages. To do this I created the product class that
> contains this simple properties:
>
> 
> public virtual string Name { get; set; }
> public virtual IDictionary CultureTexts
> {
>  get { return cultureTexts; }
>  protected set { cultureTexts = value; }
> }
> private IDictionary cultureTexts = new
> Dictionary();
> 
>
> and a CultureText class that contains this:
>
> 
> public virtual string Description { get; set; }
> public virtual string OtherDetails { get; set; }
> 
>
> The mapping is as follows:
>
>  
>
>  
>Product_Sequence
>  
>
>
>
>  
>  
>  
>
>
>  
>
>  
>
> The problem is that when the texts are null (both properties)
> collection is not loaded and errors begin to occur.
>
> I found this bug in Hibernate:
> http://opensource.atlassian.com/projects/hibernate/browse/HHH-3836
>
> There seems to be the same problem with NHibernate.
>
> Someone can help me with this problem? (some workaround)
>
> Thanks in advance
>
> >
>


-- 
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] Property with Oracle´s sequence?

2009-07-01 Thread brulimat

 Hi guys!

 I have a question.

 My IDs are GUID but a specific property is an index column.
 This column uses Oracle´s Sequence.
 My question is: How to use a Oracle`s Sequence into a property?


 Sorry, but I´m a newbie.

 Thank you.

 Bruno.

--~--~-~--~~~---~--~~
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] Composite-element with null columns in map is ignored

2009-07-01 Thread ernestmartin

Hello everyone.

I'm trying make an entity containing a dictionary with their texts in
several languages. To do this I created the product class that
contains this simple properties:


public virtual string Name { get; set; }
public virtual IDictionary CultureTexts
{
  get { return cultureTexts; }
  protected set { cultureTexts = value; }
}
private IDictionary cultureTexts = new
Dictionary();


and a CultureText class that contains this:


public virtual string Description { get; set; }
public virtual string OtherDetails { get; set; }


The mapping is as follows:

  

  
Product_Sequence
  



  
  
  


  

  

The problem is that when the texts are null (both properties)
collection is not loaded and errors begin to occur.

I found this bug in Hibernate: 
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3836

There seems to be the same problem with NHibernate.

Someone can help me with this problem? (some workaround)

Thanks in advance

--~--~-~--~~~---~--~~
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] Problem with collection loading - unit test sometimes passes, sometimes not

2009-07-01 Thread epitka

I have a very unusual problem with one relationship in my class (and
only this one) out of some 60 classes. Problem is that the unit test
that tests mapping passes on my local machine, but fails on the build
server. Mind you everything is pointing to the same database, problem
is not with a data. Problem is that on my machine, when unit test is
run, collection is uninitialized until accessed. On the server, is
shows as initialized. Here is the unit test (please do not comment on
unit test itself, it is what it is):

[Test]
public void Can_Load_With_ClientNotes()
{
Domain.Client.Entities.Client client =
clientRepository.FindByNumber(261).FirstOrDefault();
Assert.That(client, Is.Not.Null);

Assert.That(NHibernateUtil.IsInitialized
(client.LazyNotes),Is.False, "IsInitialized - before");

NHibernateUtil.Initialize(client.LazyNotes);

Assert.That(NHibernateUtil.IsInitialized
(client.LazyNotes), Is.True, "IsInitialized - after");

Assert.That(client.LazyNotes.Any(),Is.True, "LazyNotes");

Assert.That(client.LazyNotes.Count(), Is.GreaterThan(0));
}

Here is the mapping for the Client and ClientNote

ClientMap

public class ClientMap : ClassMap
{
public ClientMap()
{
DefaultAccess.AsCamelCaseField(Prefix.Underscore);
WithTable("vw_Client");

Id(x => x.Id, "ClientId");

Map(x => x.Name, "ClientNameTxt");
Map(x => x.Number, "ClientNum");
Map(x => x.EnrollmentSize, "EnrollmentSizeNum");

References(x => x.AccountType, "AcctTypeCd");
References(x => x.LineOfBusiness, "LineOfBusinessCd");

HasMany(x => x.EagerNotes).KeyColumnNames.Add
("ClientId").Not.LazyLoad();
HasMany(x => x.LazyNotes).KeyColumnNames.Add
("ClientId").LazyLoad().AsBag();

HasMany(x => x.AccountTypeHistory)
  .KeyColumnNames.Add("ClientId")
  .Cascade.SaveUpdate();


ClientNote:

 public class ClientNoteMap : ClassMap
{
public ClientNoteMap()
{
DefaultAccess.AsCamelCaseField(Prefix.Underscore);

WithTable("vw_D_ClientNote");

Id(x => x.Id, "NoteId");

Map(x => x.Subject, "NoteSubjectTxt");
Map(x => x.CreationDate, "NoteCrtDt");
Map(x => x.ShortText, "NoteShrtTxt");
Map(x => x.Text, "NoteTxt");
}
}

Facts:

1. this  Assert.That(NHibernateUtil.IsInitialized
(client.LazyNotes),Is.False, "IsInitialized - before"); passes on my
machine, and same code fails on build server.

2. I take this dll and put it in the web bin directory, and I step
through the code and this is what I see for generated proxy. All other
collections are as PersistentGenericBag, except for LazyNotes? How
come?

?CurrentBid.Client
{ClientProxybef6f8a3309c43f7b7b98a0d8f36d526}
[ClientProxybef6f8a3309c43f7b7b98a0d8f36d526]:
{ClientProxybef6f8a3309c43f7b7b98a0d8f36d526}
base {SR.Domain.Common.Infrastructure.PersistentObject}:
{ClientProxybef6f8a3309c43f7b7b98a0d8f36d526}
AccountType: {AccountTypeProxyf2cfb29f153b4e8abd4cfcc946b97213}
AccountTypeHistory:
{NHibernate.Collection.Generic.PersistentGenericBag}
ClientType: null
EagerNotes: Count = 0
EnrollmentSize: 35161
LazyNotes: Count = 0
LineOfBusiness:
{LineOfBusinessProxy7010d97df001455f8e464a03477c23d3}
Name: "Purdue University"
Number: 261



--~--~-~--~~~---~--~~
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 guid.comb for character(36)

2009-07-01 Thread Kenneth Siewers Møller
Well, I ended up creating a simple enhanced usertype converting from string
to guid and vice verca... It's actually a very crude implementation, but
does what is intended.

Am I correct to assume that IEnhancedUserType is the right approach for a
custom identifier type?


2009/7/1 Fabio Maulo 

> 2009/7/1 Kenneth Siewers Møller 
>
>> Okay, the db type "bytea" is in fact binary data... So, with this in
>> place, how can I persist a Guid in that?
>
>
> Take care. The matter is not only the representation but how the
> DataProvider will interpret a Guid parameter.
>
> --
> 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 guid.comb for character(36)

2009-07-01 Thread Fabio Maulo
2009/7/1 Kenneth Siewers Møller 

> Okay, the db type "bytea" is in fact binary data... So, with this in place,
> how can I persist a Guid in that?


Take care. The matter is not only the representation but how the
DataProvider will interpret a Guid parameter.

-- 
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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Graham Bunce

Thanks

Some interesting pointers (LEFT JOIN FETCH) which I've tried but the
final option seems to be to drop down to raw SQL. I'd rather not and
would rather face the complexities (to me anyway!) of criteria
queries. Can this do the recursive (max 3 levels) with sorting that
I'm after?
--~--~-~--~~~---~--~~
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 guid.comb for character(36)

2009-07-01 Thread Kenneth Siewers Møller
Okay, the db type "bytea" is in fact binary data... So, with this in place,
how can I persist a Guid in that?

2009/7/1 Kenneth Siewers Møller 

> Hmm, unfortunately there isn't any binary column. I guess theres a byte
> array ("bytea"), but i don't know if that's any good.
> I can see your point in using character(36) is a bad idea, but I was simply
> just copying the guid generated from .NET (which includes the dashes),
> thinking that a plain character string in the same length would be enough.
> My current implementation isn't that advanced, so indexing isn't a real
> issue at the moment.
>
> My point is also that I need to be able to convert the column to a "real"
> uuid when we make a switch to the new version at some point (8.3)...
>
> 2009/7/1 Ken Egozi 
>
> a guid is a 128bit numbercharacter(36) is 288.  even if you skip the '-'
>> chars you're still at 256.  and if characters() is unicode ...
>> using a too large field for indexing, especially for PK, might not be such
>> a good idea.
>> is there any kind of a binary[128] field you can use instead?  then we'll
>> discuss the mapping
>>
>> 2009/7/1 Kenneth Siewers Møller 
>>
>> Hi
>>>
>>> This might be a simple question to answer, but here goes.
>>>
>>> We're running a PostgreSQL 8.1 DBMS, which doesn't support UUID. My idea
>>> is therefore to continue using GUID's as PK's in my domain model, but simply
>>> persist them as character(36) in the database. Is this possible? I've tried
>>> just changing the column to character(36), but this causes NH to produce the
>>> error "operator does not exist: character = uuid", which is resonable...
>>> Changing the mapping to type "string" creates a conversion exception - again
>>> quite understandable...
>>>
>>> I'd rather avoid creating a custom usertype as the DBMS probably will be
>>> upgraded at some point, making this a somewhat irellevant implementation...
>>>
>>> Any ideas?
>>>
>>>
>>>
>>
>>
>> --
>> 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: Where clause in mapping

2009-07-01 Thread Fabio Maulo
Retrieve instances by query and not using Get nor Load nor inside a
collection owned by another class and you will see how it work.Btw you must
ask your self why use the 'where' in a class mapping.
An example is here:
http://fabiomaulo.blogspot.com/2008/10/power-of-orm.html
Note:" The use of , discriminator-value and where tags is the
trick."

2009/7/1 ike bailey 

> I was reading the nhibernate reference guide to figure out how to map a
> table where a column is a certain value and i ran across this:5.1.3. class
>
> You may declare a persistent class using the class element:
>
>  name="ClassName"  (1)
> table="tableName" (2)
> discriminator-value="discriminator_value" (3)
> mutable="true|false"  (4)
> schema="owner"(5)
> proxy="ProxyInterface"(6)
> dynamic-update="true|false"   (7)
> dynamic-insert="true|false"   (8)
> select-before-update="true|false" (9)
> polymorphism="implicit|explicit"  (10)
> where="arbitrary sql where condition" (11)
> persister="PersisterClass"(12)
> batch-size="N"(13)
> optimistic-lock="none|version|dirty|all"  (14)
> lazy="true|false" (15)
> />
>
>
> (11)
>
> where (optional) specify an arbitrary SQL WHERE condition to be used when
> retrieving objects of this class
>
>
> My question is how do I use this? I've tried and I'm not sure that I'm
> using it right.
>
> Here is my mapping
>
>   
> 
>   
>   
> 
>
> 
>
>   
>
>
> --
> Isaac Bailey
>
> >
>


-- 
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: HQL / Critera query for self referencing table and order by

2009-07-01 Thread Tuna Toksoz
Does this help?

http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/05/14/how-to-map-a-tree-in-nhibernate.aspx

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike




On Wed, Jul 1, 2009 at 6:57 PM, Graham Bunce wrote:

>
> All,
>
> I'm trying to create the HQL to load an entity and all its children,
> ordering both and I'm struggling a little. It may be possible using
> Critera but I must admit I find those a little hard to understand so
> tend to use HQL.
>
> I have a self referencing table with data like the following
>
> ID,Name,Parent,Sequence
> 1, Fred, null, 0
> 2, Jack, 1, 0
> 3, Jill, 1, 1
> 4, Mary, 1, 2
> 6, Bill, null, 1
> 7, Murray, 6, 0
> 8, Katy, 6, 1
> 9, New York, 8, 0
> 10, London, 8, 1
> 11, Boston, 8, 2
>
>
> So Fred and Bill are both roots but are sorted in sequence (0,1). They
> each have their own children also sorted in sequence. As you can see,
> the Sequence numbers are sequential within their level parent. Its
> possible (i.e. Katy) for the hierarchy to continue down. In my case
> though I am only ever going to have a maximum 3 levels (root -> child -
> > child).
>
> What I'm after is HQL or the criteria query that lets me load a root
> for an id, all the children (children A) for that root sorting those
> children A by Sequence, then all the children (children B) of children
> A sorting those Children B by sequence.
>
> I tried HQL similar to LEFT JOIN FETCH but it loads duplicate roots
> and I don't think I could sort Children B with this method.
>
> Any advice please - thanks.
> >
>

--~--~-~--~~~---~--~~
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] HQL / Critera query for self referencing table and order by

2009-07-01 Thread Graham Bunce

All,

I'm trying to create the HQL to load an entity and all its children,
ordering both and I'm struggling a little. It may be possible using
Critera but I must admit I find those a little hard to understand so
tend to use HQL.

I have a self referencing table with data like the following

ID,Name,Parent,Sequence
1, Fred, null, 0
2, Jack, 1, 0
3, Jill, 1, 1
4, Mary, 1, 2
6, Bill, null, 1
7, Murray, 6, 0
8, Katy, 6, 1
9, New York, 8, 0
10, London, 8, 1
11, Boston, 8, 2


So Fred and Bill are both roots but are sorted in sequence (0,1). They
each have their own children also sorted in sequence. As you can see,
the Sequence numbers are sequential within their level parent. Its
possible (i.e. Katy) for the hierarchy to continue down. In my case
though I am only ever going to have a maximum 3 levels (root -> child -
> child).

What I'm after is HQL or the criteria query that lets me load a root
for an id, all the children (children A) for that root sorting those
children A by Sequence, then all the children (children B) of children
A sorting those Children B by sequence.

I tried HQL similar to LEFT JOIN FETCH but it loads duplicate roots
and I don't think I could sort Children B with this method.

Any advice please - thanks.
--~--~-~--~~~---~--~~
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] Where clause in mapping

2009-07-01 Thread ike bailey
I was reading the nhibernate reference guide to figure out how to map a
table where a column is a certain value and i ran across this:5.1.3. class

You may declare a persistent class using the class element:




(11)

where (optional) specify an arbitrary SQL WHERE condition to be used when
retrieving objects of this class


My question is how do I use this? I've tried and I'm not sure that I'm using
it right.

Here is my mapping

  

  
  




  


-- 
Isaac Bailey

--~--~-~--~~~---~--~~
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 guid.comb for character(36)

2009-07-01 Thread Kenneth Siewers Møller
Hmm, unfortunately there isn't any binary column. I guess theres a byte
array ("bytea"), but i don't know if that's any good.
I can see your point in using character(36) is a bad idea, but I was simply
just copying the guid generated from .NET (which includes the dashes),
thinking that a plain character string in the same length would be enough.
My current implementation isn't that advanced, so indexing isn't a real
issue at the moment.

My point is also that I need to be able to convert the column to a "real"
uuid when we make a switch to the new version at some point (8.3)...

2009/7/1 Ken Egozi 

> a guid is a 128bit numbercharacter(36) is 288.  even if you skip the '-'
> chars you're still at 256.  and if characters() is unicode ...
> using a too large field for indexing, especially for PK, might not be such
> a good idea.
> is there any kind of a binary[128] field you can use instead?  then we'll
> discuss the mapping
>
> 2009/7/1 Kenneth Siewers Møller 
>
> Hi
>>
>> This might be a simple question to answer, but here goes.
>>
>> We're running a PostgreSQL 8.1 DBMS, which doesn't support UUID. My idea
>> is therefore to continue using GUID's as PK's in my domain model, but simply
>> persist them as character(36) in the database. Is this possible? I've tried
>> just changing the column to character(36), but this causes NH to produce the
>> error "operator does not exist: character = uuid", which is resonable...
>> Changing the mapping to type "string" creates a conversion exception - again
>> quite understandable...
>>
>> I'd rather avoid creating a custom usertype as the DBMS probably will be
>> upgraded at some point, making this a somewhat irellevant implementation...
>>
>> Any ideas?
>>
>>
>>
>
>
> --
> 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: How to handle default entities

2009-07-01 Thread David Perfors

A quick writeup can be found here:
http://nhforge.org/wikis/howtonh/prefent-nhibernate-from-saving-default-relations.aspx

On Jul 1, 8:33 am, Caio Kinzel Filho  wrote:
> Have you found a solution for that already?
>
> On Mon, Jun 22, 2009 at 4:47 AM, David Perfors wrote:
>
> > Sure no problem, will do it this week...
>
> > On Jun 19, 3:21 pm, Fabio Maulo  wrote:
> >> 2009/6/19 David Perfors 
>
> >> > Instead of using the above method I use the FlushEntity event to set
> >> > the reference to null when it has the default value, and the LoadEvent
> >> > to set the reference to the NoTaxCalculator when the value is null.
> >> > That works like a charm...
>
> >> Do you want share your code in NH-Forge wiki or blog ?
>
> >> --
> >> 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: Defining a user type for decimal with precision

2009-07-01 Thread Fabio Maulo
In NH2.0 you can use:type="Decimal(36,18)"

2009/7/1 Stefan Steinegger 

>
> Thanks for the hint. I will test it with version 2.1
>
> This is a major issue for us, because we are on 2.0 now and I have a
> user type just to make sure that the precision is on 36,18. If I need
> to declare the precision when ever I map a decimal, I have a lot of
> work and a maintenance problem too.
>
> I actually hope to upgrade to 2.1 soon, but for the moment I have to
> make things work quickly ... I actually don't know what I should do
> now. I fear that the only option is to go through all the mapping
> files and define the precision ... :-(
>
>
> On 1 Jul., 15:23, Roger Kratz  wrote:
> > There were some issues with decimal db typehttp://
> nhjira.koah.net/browse/NH-1594
> >
> > Are you using latest nh bits?
> >
> > -Original Message-
> > From: nhusers@googlegroups.com [mailto:nhus...@googlegroups.com] On
> Behalf Of Stefan Steinegger
> > Sent: den 1 juli 2009 13:54
> > To: nhusers
> > Subject: [nhusers] Defining a user type for decimal with precision
> >
> > I have a user type which specifies a decimal with precision and scale
> > like this:
> >
> > public IType[] PropertyTypes
> > {
> > get
> > {
> > return new []
> > {
> > TypeFactory.GetDecimalType(36, 18),
> > TypeFactory.GetStringType(100)
> > }
> > }
> > }
> >
> > The problem is, when generating the schema, the string is fine,
> > defined with a length of 100 (default is 255), but the decimal is
> > still define as decimal(19,5).
> >
> > Is this a bug, or am I doing something wrong?
> >
>


-- 
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: Defining a user type for decimal with precision

2009-07-01 Thread Stefan Steinegger

Thanks for the hint. I will test it with version 2.1

This is a major issue for us, because we are on 2.0 now and I have a
user type just to make sure that the precision is on 36,18. If I need
to declare the precision when ever I map a decimal, I have a lot of
work and a maintenance problem too.

I actually hope to upgrade to 2.1 soon, but for the moment I have to
make things work quickly ... I actually don't know what I should do
now. I fear that the only option is to go through all the mapping
files and define the precision ... :-(


On 1 Jul., 15:23, Roger Kratz  wrote:
> There were some issues with decimal db 
> typehttp://nhjira.koah.net/browse/NH-1594
>
> Are you using latest nh bits?
>
> -Original Message-
> From: nhusers@googlegroups.com [mailto:nhus...@googlegroups.com] On Behalf Of 
> Stefan Steinegger
> Sent: den 1 juli 2009 13:54
> To: nhusers
> Subject: [nhusers] Defining a user type for decimal with precision
>
> I have a user type which specifies a decimal with precision and scale
> like this:
>
> public IType[] PropertyTypes
> {
>         get
>         {
>                 return new []
>                 {
>                         TypeFactory.GetDecimalType(36, 18),
>                         TypeFactory.GetStringType(100)
>                 }
>         }
> }
>
> The problem is, when generating the schema, the string is fine,
> defined with a length of 100 (default is 255), but the decimal is
> still define as decimal(19,5).
>
> Is this a bug, or am I doing something wrong?
--~--~-~--~~~---~--~~
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: Defining a user type for decimal with precision

2009-07-01 Thread Roger Kratz

There were some issues with decimal db type
http://nhjira.koah.net/browse/NH-1594

Are you using latest nh bits?


-Original Message-
From: nhusers@googlegroups.com [mailto:nhus...@googlegroups.com] On Behalf Of 
Stefan Steinegger
Sent: den 1 juli 2009 13:54
To: nhusers
Subject: [nhusers] Defining a user type for decimal with precision


I have a user type which specifies a decimal with precision and scale
like this:

public IType[] PropertyTypes
{
get
{
return new []
{
TypeFactory.GetDecimalType(36, 18),
TypeFactory.GetStringType(100)
}
}
}

The problem is, when generating the schema, the string is fine,
defined with a length of 100 (default is 255), but the decimal is
still define as decimal(19,5).

Is this a bug, or am I doing something wrong?



--~--~-~--~~~---~--~~
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 guid.comb for character(36)

2009-07-01 Thread Ken Egozi
a guid is a 128bit numbercharacter(36) is 288.  even if you skip the '-'
chars you're still at 256.  and if characters() is unicode ...
using a too large field for indexing, especially for PK, might not be such a
good idea.
is there any kind of a binary[128] field you can use instead?  then we'll
discuss the mapping

2009/7/1 Kenneth Siewers Møller 

> Hi
>
> This might be a simple question to answer, but here goes.
>
> We're running a PostgreSQL 8.1 DBMS, which doesn't support UUID. My idea is
> therefore to continue using GUID's as PK's in my domain model, but simply
> persist them as character(36) in the database. Is this possible? I've tried
> just changing the column to character(36), but this causes NH to produce the
> error "operator does not exist: character = uuid", which is resonable...
> Changing the mapping to type "string" creates a conversion exception - again
> quite understandable...
>
> I'd rather avoid creating a custom usertype as the DBMS probably will be
> upgraded at some point, making this a somewhat irellevant implementation...
>
> Any ideas?
>
> >
>


-- 
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] Using guid.comb for character(36)

2009-07-01 Thread Kenneth Siewers Møller
Hi

This might be a simple question to answer, but here goes.

We're running a PostgreSQL 8.1 DBMS, which doesn't support UUID. My idea is
therefore to continue using GUID's as PK's in my domain model, but simply
persist them as character(36) in the database. Is this possible? I've tried
just changing the column to character(36), but this causes NH to produce the
error "operator does not exist: character = uuid", which is resonable...
Changing the mapping to type "string" creates a conversion exception - again
quite understandable...

I'd rather avoid creating a custom usertype as the DBMS probably will be
upgraded at some point, making this a somewhat irellevant implementation...

Any ideas?

--~--~-~--~~~---~--~~
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] Defining a user type for decimal with precision

2009-07-01 Thread Stefan Steinegger

I have a user type which specifies a decimal with precision and scale
like this:

public IType[] PropertyTypes
{
get
{
return new []
{
TypeFactory.GetDecimalType(36, 18),
TypeFactory.GetStringType(100)
}
}
}

The problem is, when generating the schema, the string is fine,
defined with a length of 100 (default is 255), but the decimal is
still define as decimal(19,5).

Is this a bug, or am I doing something wrong?
--~--~-~--~~~---~--~~
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 a relation not on primary key

2009-07-01 Thread Maik

I know, that this is a bad design, but we also use a legacy database.
Thanks for your help!



On 1 Jul., 12:04, Stefan Steinegger 
wrote:
> You should actually avoid this.
>
> If have to cope with a legacy database, use property-ref:
>
> class Class1
> {
>   //...
>   public Guid BusinessId { get; set; }
>
> }
>
> class Class2
> {
>   //...
>   public MyClass1 { get; set; }
>
> }
>
> 
>   
>        name="MyClass1"
>     class="Class1"
>     property-ref="BusinessId"
>     column="MyTAB1" />
> 
>
> On 1 Jul., 08:40, Maik  wrote:
>
> > Hi folks,
>
> > I have a question, because I couldn't find it by flying through the
> > manual and google.
>
> > How do I map a relation on a UniqueKey in the foreign Table?
>
> > I mean sth. like this:
>
> > TABLE1:
> > ID *(PK)
> > BUSINESS_ID (Unique or NULL)
> > NAME
>
> > TABLE2:
> > ID *(PK)
> > MY_TAB1 (FK to TABLE1 by BUSINESS_ID)
> > INFORMATION
>
> > Thanks for your help
>
> > Regards,
> > Maik
>
>
--~--~-~--~~~---~--~~
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 a relation not on primary key

2009-07-01 Thread Stefan Steinegger

You should actually avoid this.

If have to cope with a legacy database, use property-ref:

class Class1
{
  //...
  public Guid BusinessId { get; set; }
}

class Class2
{
  //...
  public MyClass1 { get; set; }
}


  
  


On 1 Jul., 08:40, Maik  wrote:
> Hi folks,
>
> I have a question, because I couldn't find it by flying through the
> manual and google.
>
> How do I map a relation on a UniqueKey in the foreign Table?
>
> I mean sth. like this:
>
> TABLE1:
> ID *(PK)
> BUSINESS_ID (Unique or NULL)
> NAME
>
> TABLE2:
> ID *(PK)
> MY_TAB1 (FK to TABLE1 by BUSINESS_ID)
> INFORMATION
>
> Thanks for your help
>
> Regards,
> Maik
--~--~-~--~~~---~--~~
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: What's the point of inverse=false?

2009-07-01 Thread Roger

<>

In monodirectional relationships.

I would guess the reason this is not "happening by default" in
bidirectional one-to-many refs is to have consistent behaviour with
other mappings such as many-to-many refs where you need to choose one
side. I'm not sure though...

To answer your question - if you have have a bidirectional one-to-many
rel, always use inverse=true.

/Roger

On Jun 30, 2:49 pm, James Allen 
wrote:
> I have been trying to get to grips with Hibernate's inverse attribute,
> and it seems to be just one of those things that is conceptually
> difficult.
>
> The gist that I get is that when you have a parent entity (e.g.
> Parent) that has a collection of Child objects using a one-to-many
> mapping, setting inverse=true on the mapping tells Hibernate that 'the
> other side (the Child) has responsibility to update itself to maintain
> the foreign key reference in its table'.
>
> Doing this appears to have 2 benefits when it comes to adding Children
> to the collection in your code, and then saving the Parent: you save
> an unneccessary hit on the database (because without inverse set,
> Hibernate thinks it has two places to update the FK relationship) 
> (seehttp://nhprof.com/Learn/Alert?name=SuperfluousManyToOneUpdate), and
> according to the official docs:
>
> "If the column of a association is declared NOT NULL, NHibernate may
> cause constraint violations when it creates or updates the
> association. To prevent this problem, you must use a bidirectional
> association with the many valued end (the set or bag) marked as
> inverse="true"."
>
> This all seems to make sense so far. What I don't get is this: when
> would you NOT want to use inverse=true on a one-to-many relationship?
--~--~-~--~~~---~--~~
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: One to Many Newbie Question

2009-07-01 Thread Dave

Read this article it explains most of the different mappings with
examples

http://www.codeproject.com/KB/database/Nhibernate_Made_Simple.aspx


On Jul 1, 10:22 am, usbsnowcrash  wrote:
> I have two tables Game and Genre.  Each game can have 0 or more
> genres.  I have a table that manages this mapping that has a composite
> key pointing back to the primary keys on Game and Genre.  Here is a
> visual:
>
> Game
> --
> *GameID
> GameName
>
> GameGenres
> --
> *GameID
> *GenreID
>
> Genre
> --
> *GenreID
> GenreName
>
> I am pretty new to NHibernate and I am unsure how I would create a
> ma
ppin
g for this scenario.  Can anyone help me out?
--~--~-~--~~~---~--~~
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] One to Many Newbie Question

2009-07-01 Thread usbsnowcrash

I have two tables Game and Genre.  Each game can have 0 or more
genres.  I have a table that manages this mapping that has a composite
key pointing back to the primary keys on Game and Genre.  Here is a
visual:

Game
--
*GameID
GameName

GameGenres
--
*GameID
*GenreID

Genre
--
*GenreID
GenreName

I am pretty new to NHibernate and I am unsure how I would create a
mapping for this scenario.  Can anyone help me out?

--~--~-~--~~~---~--~~
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 SQL Generation Issue

2009-07-01 Thread naz

Hi,

I get this error when executing the generated SQL - Ambiguous column
name.

It seems somehow the latest version of Castle I downloaded does not
alias the order by clause.

The old version use to work but this seems like a possible bug in the
latest version of NHibernate.

Anyone else experiencing this issue or know of a solution.

Thanks

--~--~-~--~~~---~--~~
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: newbie question what do i need to do to enable database deletion on unit test setup

2009-07-01 Thread theghost

Thanks that was it:

 Pooling=false;

 added to connection string fixed it!

On Jul 1, 5:22 pm, Oskar Berggren  wrote:
> Look up connection pooling (ADO.NET, below NHibernate) and how to turn
> this off for the Firebird ADO.NET driver. This is possibly a parameter
> in you connection string.
>
> /Oskar
>
> 2009/6/30 theghost :
>
>
>
> > Hi,
> > As part of learning nhibernate i am trying to set up some basic unit
> > tests. As part of the set up I blow away and re-copy a small firebird
> > database to my testing directory. I am having a problem though, in
> > that somehow I am holding onto a database connection after each test
> > so although any test will pass on its own my setup fails if I try to
> > run 2 tests in a row. An abbreviated version of the offending code is
> > as follows:
>
> >        [SetUp]
> >        public void SetUp()
> >        {
> >           // copy a new test file overwrite the old
> >           UnitTestSetUpTearDown.CopyTestFile("NHIBERNATE.FDB");
> >        }
>
> >        [Test]
> >        public void TestDoNothing()
> >        {
>
> > --- standard connection string setup etc before this results in a
> > valid Configuration  object for my test db
>
> >            cfg.AddAssembly("NhibernateExample1");
>
> >            using (var factory = cfg.BuildSessionFactory())
> >            {
> >                using (var ses = factory.OpenSession())
> >                {
> >                   using (var trans = ses.BeginTransaction())
> >                    {
> >                       trans.Commit();
> >                    }
> >                }
> >            }
> >        }
>
> >        [Test]
> >        public void TestDoNothingAgain()
> >        {
> >            TestDoNothing();
> >        }
>
> > SetUp before TestDoNothingAgain() seems to have trouble deleting the
> > old database file. Anything short of commenting out:
>
> > using (var trans = ses.BeginTransaction())
> > {
> >     trans.Commit();
> > }
>
> > doesn't seem to work.. have tried calling every procedure I can find
> > that might be to do with closing connections on both trans and ses but
> > no luck.
>
> > Any suggestions as to what i need to do to delete this file?
>
> > Error is as folllows:
>
> > NHibernate.Examples.QuickStart.UnitTestingClasses.TestDoNothingAgain:
> > System.IO.IOException : The process cannot access the file 'C:
> > \Documents and Settings\Administrator\Local Settings\Temp
> > \nunit20\ShadowCopyCache\3944_633820564853125000\Tests\assembly
> > \dl3\d63c7fa7\7439d31b_07fac901\NHIBERNATE.FDB' because it is being
> > used by another process.
>
> > at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> > at System.IO.File.Delete(String path)
> > at UnitTestUtilities.UnitTestSetUpTearDown.CopyTestFile(String
> > testFileNoDir) in C:\Documents and Settings\Administrator\My Documents
> > \Visual Studio 2008\Projects\utilityClasses
> > \UnitTestSetUpTearDownProcs.cs:line 28
> > at NHibernate.Examples.QuickStart.UnitTestingClasses.SetUp() in C:
> > \Documents and Settings\Administrator\My Documents\Visual Studio
> > 2008\Projects
> > \NhibernateExample1\NhibernateExample1\UnitTestingClasses.cs:line 131
--~--~-~--~~~---~--~~
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: newbie question what do i need to do to enable database deletion on unit test setup

2009-07-01 Thread Oskar Berggren

Look up connection pooling (ADO.NET, below NHibernate) and how to turn
this off for the Firebird ADO.NET driver. This is possibly a parameter
in you connection string.

/Oskar


2009/6/30 theghost :
>
> Hi,
> As part of learning nhibernate i am trying to set up some basic unit
> tests. As part of the set up I blow away and re-copy a small firebird
> database to my testing directory. I am having a problem though, in
> that somehow I am holding onto a database connection after each test
> so although any test will pass on its own my setup fails if I try to
> run 2 tests in a row. An abbreviated version of the offending code is
> as follows:
>
>        [SetUp]
>        public void SetUp()
>        {
>           // copy a new test file overwrite the old
>           UnitTestSetUpTearDown.CopyTestFile("NHIBERNATE.FDB");
>        }
>
>        [Test]
>        public void TestDoNothing()
>        {
>
> --- standard connection string setup etc before this results in a
> valid Configuration  object for my test db
>
>            cfg.AddAssembly("NhibernateExample1");
>
>            using (var factory = cfg.BuildSessionFactory())
>            {
>                using (var ses = factory.OpenSession())
>                {
>                   using (var trans = ses.BeginTransaction())
>                    {
>                       trans.Commit();
>                    }
>                }
>            }
>        }
>
>        [Test]
>        public void TestDoNothingAgain()
>        {
>            TestDoNothing();
>        }
>
> SetUp before TestDoNothingAgain() seems to have trouble deleting the
> old database file. Anything short of commenting out:
>
> using (var trans = ses.BeginTransaction())
> {
>     trans.Commit();
> }
>
> doesn't seem to work.. have tried calling every procedure I can find
> that might be to do with closing connections on both trans and ses but
> no luck.
>
> Any suggestions as to what i need to do to delete this file?
>
> Error is as folllows:
>
> NHibernate.Examples.QuickStart.UnitTestingClasses.TestDoNothingAgain:
> System.IO.IOException : The process cannot access the file 'C:
> \Documents and Settings\Administrator\Local Settings\Temp
> \nunit20\ShadowCopyCache\3944_633820564853125000\Tests\assembly
> \dl3\d63c7fa7\7439d31b_07fac901\NHIBERNATE.FDB' because it is being
> used by another process.
>
> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
> at System.IO.File.Delete(String path)
> at UnitTestUtilities.UnitTestSetUpTearDown.CopyTestFile(String
> testFileNoDir) in C:\Documents and Settings\Administrator\My Documents
> \Visual Studio 2008\Projects\utilityClasses
> \UnitTestSetUpTearDownProcs.cs:line 28
> at NHibernate.Examples.QuickStart.UnitTestingClasses.SetUp() in C:
> \Documents and Settings\Administrator\My Documents\Visual Studio
> 2008\Projects
> \NhibernateExample1\NhibernateExample1\UnitTestingClasses.cs:line 131
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Why cascade does not working ?

2009-07-01 Thread Oskar Berggren

2009/7/1 Fernando Zago :
> I made the changes in the entity, but i don't want that nhibernate persist
> them.
> I want nhibernate to persist what is cascade="save-update".

The cascade has to do with your root having or gaining reference to
objects that are not already persisted, or that aren't "owned" by your
ISession. For example, if you load a region from the database and do
region.Country = new Country(), then cascade="save-update" will cause
NHibernate to automatically persist the Country instance, but with
cascade="none", the new Country will no be saved. However, if you
Country is already owned by an ISession, it is dirty-tracked
regardless of any references to it.

I try to follow the principle that a persisted object is a persisted
object. Don't change it if you don't want to persist the changes - at
least unless you can rollback the whole transaction or unit-of-work.

If you really have to change the Country, perhaps you could experiment
with evicting it from the session first.

/Oskar

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