-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: default-lazy / lazy
PostPosted: Wed Dec 26, 2007 10:45 pm 
Newbie

Joined: Wed Dec 26, 2007 10:32 pm
Posts: 10
Under the nhibernate-mapping-2.0 schema, there was a default-lazy="true|false" attribute on the class element, but nhibernate-mapping-2.2 omits this, instead there's a lazy="true|false" attribute. But I don't know if it's a direct replacement or not.

The schema documentation for lazy="" says it controls the Lazy Loading of a class in associations, whereas the default-lazy attribute defines whether all members of a class are to be lazy-loaded or not (or something like that).

The 1.2 migration guide says to use default-lazy (and mentions the 2.2 schema), but when I do NHibernate throws an exception:

Code:
W3b.Foo.Tests.BarProviderTests.TestProcedureAdd : System.TypeInitializationException : The type initializer for 'W3b.Foo.Provider.NHibernateHelper' threw an exception.
  ----> NHibernate.MappingException : W3b.Foo.Biz.Source.hbm.xml(4,39): XML validation error: The 'default-lazy' attribute is not declared.
  ----> System.Xml.Schema.XmlSchemaException : The 'default-lazy' attribute is not declared.


My class is sealed and has no virtual members, so should I be setting the lazy attribute to "false" in my class mapping XML?[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 27, 2007 7:24 pm 
Beginner
Beginner

Joined: Wed Jul 11, 2007 7:21 pm
Posts: 21
Location: San Diego, CA
In 2.2 it moved to:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="true">

So it's in the top level declaration. Also, in 3.0 (I think that's the new one the Java kids got), the default is now lazy, so you don't need to specificy it any longer unless you want to switch back to false, which you can still do at the class / collection level obviously.

This might very well be the first time I've actually been able to give, instead of recieve, help on Hibernate. :-)

_________________
http://rebelheart.squarespace.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 27, 2007 8:47 pm 
Newbie

Joined: Wed Dec 26, 2007 10:32 pm
Posts: 10
ericfkaufman wrote:
In 2.2 it moved to:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="true">

So it's in the top level declaration. Also, in 3.0 (I think that's the new one the Java kids got), the default is now lazy, so you don't need to specificy it any longer unless you want to switch back to false, which you can still do at the class / collection level obviously.


Ah great, thanks. The documentation was a little ambiguous.

ericfkaufman wrote:
This might very well be the first time I've actually been able to give, instead of recieve, help on Hibernate. :-)


I'm just getting started myself, I'm working on a small-ish project for a client and thought I'd try NHibernate out, everyone was hyping about it and I didn't feel like writing reams of database code.

But the way it works with just a single call to .Save and a mapping file is just voodoo.

So whilst I can see it works fine when you've got a 1:1 relationship between classes and tables, what happens if a class' members mirror the result of say... a View or Sproc?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 4:29 pm 
Beginner
Beginner

Joined: Wed Jul 11, 2007 7:21 pm
Posts: 21
Location: San Diego, CA
One of the things that I like about Hibernate is that it has made me a much better object oriented programmer. You can strong arm it into working in odd ways, but if you stay true to form with it, Hibernate is most happy in a very object oriented world.

I've abandoned stored procedures at the moment. For over ten years, I never once did NOT use a stored procedure, and I regarded dynamic sql as a hallmark of an inexperienced developer. In many ways, it still is.

If I *need* the performance of a stored procedure, or more than likely, if I *need* a sql feature that I don't find comparible in hibernate (like full text searching), I'll bypass Hibernate all together for that particular function and go back to doing it by hand. I'm currently working on an application that has well over 500 not-just-container classes, and we've had to break from Hibernate's HQL maybe 5-10 times. I think all but one of those was for full text searching.

The relational model and the hierarchy of an object graph model are different, but complementary. Hibernate lets you glue them together.

However, there is ample support for stored procedures, and sql (as opposed to hql). But really, I would spend the time mastering hibernate. The cost and time savings is amazing. It's taken me about six months of day in and day out programming to really get the hang out of it, but now it's *fairly* smooth sailing.

_________________
http://rebelheart.squarespace.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 06, 2008 7:33 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
Eric

For full text searching, try out NHibernate Search, it's not perfect by any means but it allows you to additionally store your domain objects in a full text index (using Lucence.Net) and query on that index, but return the domain object.

I'm working on the rest of the port of this from Hibernate 3.0, so if you can have a play and find out anything you need practically, I'd be most grateful.

Regards

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.