CSLA .NET

From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books

ProjectTracker.NHibernate and NHibernate v1.2

rated by 0 users
This post has 15 Replies | 4 Followers

Not Ranked
Points 155
fernandoacorreia Posted: Thu, Oct 18 2007 5:05 AM
I found DavidDilworth's excellent ProjectTracker.NHibernate project on CodePlex and I'm planning to use its framework on my next project.

I wonder if anyone has upgraded NHibernate support for CSLA to version 1.2 of NHibernate.

If anyone could share some information on this, I'd appreciate. I plan on upgrading the current ProjectTracker.NHibernate (May 3 at 6:30 AM) to NHibernate 1.2 and post it back on CodePlex.

I'd specially like to hear what David thinks about this.

Thanks and best regards.

Fernando.
  • | Post Points: 50
Top 25 Contributor
Points 3,105

Seems like an excellent idea to me. 

We have been stuck using the older version of NHibernate as we are doing project specific work right now.  We don't have the time to go back and re-engineer the framework to the new NHibernate v1.20.

Give it a try!

  • | Post Points: 20
Not Ranked
Points 155
Thank you for your feedback. I've uploaded the updated version to CodePlex as a patch. Currently it doesn't show on the "Recent Check-Ins" page, but it is listed on the "Patches" page and can be downloaded with this URL:

http://www.codeplex.com/CSLAcontrib/Project/Download/FileDownload.aspx?DownloadId=20672

Release notes:

* Updated to NHibernate 1.2
* Updated to CSLA 3.0.2.
* Folder PTData: Contains SQL Server database scripts that should be used to create the PTracker and the Security databases.
* Source code reformated with ReSharper.
* Tested with ProjectTracker 3.0.2. Web and WinForms interfaces were tested using local DataPortal. Not successful with WCF DataPortal.
  • | Post Points: 20
Top 25 Contributor
Points 3,105

I took the ZIP and it builds fine for me.

Did you make any code changes?  Or did you just update the references?

Did you change any code to take advantage of any of the new features in NHibernate v1.2 to support generics?

  • | Post Points: 20
Not Ranked
Points 155
These modifications were required to make it work with NHibernate 1.2:
  • Update DLLs required by NHibernate.
  • Add xmlns='urn:nhibernate-configuration-2.2' to some XML files.
  • Add Lazy = false to class attributes.
I'm sorry about all the reformatting. I realize it makes it impossible to review my changes. But they can be easily applied to the original version. Just search for urn:nhibernate-configuration-2.2 and Lazy = false and you'll see where I made these changes.

I did not try to add support for generics right now. Actually I'm creating another framework based on this one that will use the DAL pattern to avoid binding the business object to NHibernate. That way the BO could be used on Silverlight 1.1 without requiring NHibernate on the client.

Cheers!
  • | Post Points: 20
Top 25 Contributor
Points 3,105

Don't worry about the formatting.  We obviously have different style settings for R#, since that's what we use as well.

I, incorrectly as it turns out, assumed that you were also going to look at how to use the new generics stuff as well.

That will obviously have to wait for another day!

  • | Post Points: 5
Not Ranked
Points 70
 Why is   not successful with WCF DataPortal?
  • | Post Points: 20
Top 25 Contributor
Points 3,105

There should be no reason why it shouldn't work with WCF.  NHibernate is used only to populate the objects with data from the data base.

If you have a problem with remoting and WCF then it's likely that you haven't configured the various parts of the Data Portal functionality correctly.

Double check all your WCF configuration settings and make sure you can get the Data Portal working without NHibernate.  Then add NHibernate into the picture.  That might help you isolate the problem.

However, having said all that we haven't gone up to the latest version of CSLA yet that takes advantage of the WCF stuff.  So there may be a problem that we haven't seen yet.

  • | Post Points: 20
Not Ranked
Points 70

ProjectList.cs

protected override void SetNHibernateCriteria(object businessCriteria, ICriteria nhibernateCriteria){

 // Cast the criteria back to the strongly-typed version
            Criteria criteria = businessCriteria as Criteria;

   // If it's a valid criteria object then check for filters
            if (!ReferenceEquals(criteria, null))
            {
                // Set a reference to the NHibernate ICriteria (for local use only)
                _iCriteria = nhibernateCriteria;

                // Name
                if (!String.IsNullOrEmpty(criteria.Name))
                {
                    AddCriterionName(criteria.Name);
                }
            }

}

 

I think something is wrong here.when i remark these ,it's all right.

 

 

  • | Post Points: 20
Top 25 Contributor
Points 3,105

Well there's nothing wrong with that line of code specifically.  And you've not given any idea of what the problem is and how it's being manifested.

However, that line of code is just doing a simple assignment operation to a private field, so that the AddCriterionName() method can use the field.

It can be refactored easily so that the ICriteria is passed as a parameter to the AddCriterionName(ICriteria nhibernateCriteria, string Name) method instead.  Then the private field can be removed.

  • | Post Points: 20
Not Ranked
Points 70

some details is here

http://forums.lhotka.net/forums/thread/20880.aspx

  • | Post Points: 20
Top 25 Contributor
Points 3,105

I read the other thread.  And yes, it sounds to me like you found the right problem - Serialization.

Any BO that needs to move via the Data Portal has to be Serializable.  And sometimes that means you might need to mark specific fields with the [NonSerialized] attribute.

I hope you solved your problem.

  • | Post Points: 20
Top 500 Contributor
Points 340
Cine replied on Mon, Apr 14 2008 5:40 AM
Anyone looked into upgrading to 2.0 (alpha 1 at this point in time)?
  • | Post Points: 5
Top 150 Contributor
Points 630
andy replied on Fri, Aug 29 2008 9:00 AM
Hi David,
I have reviewed your implementation ProjectTrackerNHibernate solution.
It looks very good to me.  Any code base template for it?
I am just started to work with NH.  The learning curve is quite steep, but did find a lot of resources to help me with along the way.
Currently I am using CSLA framework for my project and would like to leverage ORM framework to do the CRUD operations.  This could lead to 90% code reduction for data access code in dataportal_xyz operations.  The remaining 10% might be dealing with sharp edges.
I am current testing NH 1.2 and it required all properties and methods of POCO to be virtual.
No biggy, I can use mygenerate tool to do the dirty works.:)
I am using ORALC Eand ODP.NET for my environment.  There are very limited on internet about the topic. 
Seems you had experienced using NH & CLSA in your project.
Any "gothcha"(i.e session manager, lazy loading, etc) that I should be concerned?
I appreciate you sharing your knowledge and time.

Andy

  • | Post Points: 20
Top 500 Contributor
Points 275
Philip replied on Wed, Oct 15 2008 9:37 AM

I am looking into writing some templates to support NHibernate in Code Complete. I am not very familiar with NHibernate so I have a couple of questions and I would appreciate any help:

1- How is NH used with CSLA i.e. does everyone use the version by David Dilworth available on CodePlex?

2- Which version is currently available as a release?

Thanks

Philip

  • | Post Points: 20
Page 1 of 2 (16 items) 1 2 Next > | RSS

Please contact Magenic for your .NET consulting
and CSLA .NET mentoring needs.
Please consider making a donation to help support the ongoing development of CSLA .NET.

Make donation through PayPal - it's fast, free and secure!
Why donate?
Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems