ProjectTracker.NHibernate and NHibernate v1.2

ProjectTracker.NHibernate and NHibernate v1.2

Old forum URL: forums.lhotka.net/forums/t/3740.aspx


fernandoacorreia posted on Thursday, October 18, 2007

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.

DavidDilworth replied on Tuesday, October 23, 2007

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!

fernandoacorreia replied on Wednesday, October 24, 2007

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.

DavidDilworth replied on Thursday, October 25, 2007

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?

fernandoacorreia replied on Thursday, October 25, 2007

These modifications were required to make it work with NHibernate 1.2:
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!

DavidDilworth replied on Thursday, October 25, 2007

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!

lonely7345 replied on Friday, February 15, 2008

 Why is   not successful with WCF DataPortal?

DavidDilworth replied on Tuesday, February 19, 2008

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.

lonely7345 replied on Tuesday, February 19, 2008

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.

 

 

DavidDilworth replied on Wednesday, February 20, 2008

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.

lonely7345 replied on Saturday, February 23, 2008

some details is here

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

DavidDilworth replied on Tuesday, March 04, 2008

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.

andy replied on Friday, August 29, 2008

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

Philip replied on Wednesday, October 15, 2008

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

DavidDilworth replied on Wednesday, October 15, 2008

I'm just replying to this so that people who come to this thread will find out that I have moved on to a new job and I am no longer involved in the project that used CSLA and NH together.  As it happens, I'm still using NH, but with an in-house developed middle tier.  I still get the occasional CSLA email and I do check back onto the forums occasionally - there are some very knowledgable people on here!

So in answer to your questions:

(1) I don't know, but I expect some people will have taken the original CodePlex code and modified it for their own projects.  That's great, it was always meant to be a starting point to give people an idea of how CSLA and NH could be integrated together.

(2) NHibernate is at version 1.2.1.  Check out the NHibernate website for the latest updates.  As for the latest version of the CSLA/NH extensions - I'm not sure anymore.

HTH

And good luck!

 

Cine replied on Monday, April 14, 2008

Anyone looked into upgrading to 2.0 (alpha 1 at this point in time)?

Copyright (c) Marimer LLC