66366 members! Sign up to stay informed.

Sponsored Links


Resources

.NET Research Library
Get .NET related white papers, case studies and webcasts

News News News Messages: 36 Messages: 36 Messages: 36 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Introducing NHibernate

Posted by: Nitin Bharti on August 12, 2004 DIGG
In this latest installment, Justin Gehtland discusses NHibernate, the .NET port of the open-source Java Hibernate object/relational mapping library developed by Gavin King (now of JBoss). Read about how to use NHibernate to avoid clumsy relational queries that clutter your code.

Next month, look for Justin's follow-up article, in which he'll discuss using parameterized queries using HQL, caching, and advanced collection semantics in NHibernate.

Read NHibernate

Threaded replies

·  Introducing NHibernate by Nitin Bharti on Thu Aug 12 15:48:08 EDT 2004
  ·  Introducing NHibernate by Bryan Murphy on Thu Aug 12 17:30:25 EDT 2004
    ·  Introducing NHibernate by javier castanon on Thu Aug 12 17:54:14 EDT 2004
      ·  Introducing NHibernate by McCorney Severin on Thu Aug 12 21:15:52 EDT 2004
      ·  Introducing NHibernate by Jon King on Thu Aug 12 21:39:44 EDT 2004
        ·  Introducing NHibernate by Surendra Jambe on Tue Aug 17 17:11:27 EDT 2004
          ·  Introducing NHibernate by Patrick Heymans on Wed Aug 18 04:36:30 EDT 2004
            ·  Re: Introducing NHibernate by Szoke Szoke on Thu Aug 26 04:19:15 EDT 2004
    ·  Introducing NHibernate by Mike Griffin on Fri Aug 13 15:38:16 EDT 2004
    ·  Error: could not load object by Koffer Shen on Mon May 30 02:06:28 EDT 2005
    ·  Could provde the sourceCode, especially the *.hbm.xml by Koffer Shen on Mon May 30 03:49:15 EDT 2005
  ·  1:1 M:1 lazy loading? by Deyan Petrov on Fri Aug 13 03:58:05 EDT 2004
    ·  What are its features status compare to Hbernate by arun sahni on Fri Aug 13 09:55:50 EDT 2004
      ·  Re: What are its features status compare to Hbernate by Szoke Szoke on Thu Aug 26 06:07:28 EDT 2004
    ·  1:1 M:1 lazy loading? by bob farmer on Fri Aug 13 10:59:52 EDT 2004
    ·  Yes, it does by Justin Gehtland on Sat Aug 14 21:38:01 EDT 2004
  ·  Introducing NHibernate by John Harby on Fri Aug 13 11:23:35 EDT 2004
  ·  Other persistence frameworks by Fernando Rodriguez on Tue Aug 17 00:11:57 EDT 2004
    ·  re: Other persistence frameworks by Fabrice Marguerie on Tue Aug 17 08:03:17 EDT 2004
  ·  Are public properties really needed? by Patrick Heymans on Tue Aug 17 07:31:47 EDT 2004
    ·  That was an error by Justin Gehtland on Tue Aug 17 14:01:31 EDT 2004
  ·  Not 100% sold by Doug Adams on Wed Aug 18 11:56:41 EDT 2004
  ·  Check your exception handling by Ingemar Lundberg on Fri Aug 20 11:23:03 EDT 2004
  ·  Int32 cannot be used as Identity Key? by Daniel Polistchuck on Wed Aug 25 14:17:00 EDT 2004
    ·  Re: Int32 cannot be used as Identity Key? by Szoke Szoke on Thu Aug 26 04:14:48 EDT 2004
      ·  Re: Int32 cannot be used as Identity Key? by Jason Davis on Thu Sep 02 09:05:25 EDT 2004
        ·  Re: Int32 cannot be used as Identity Key? by Szoke Szoke on Mon Sep 06 04:20:56 EDT 2004
    ·  Int32 cannot be used as Identity Key? by Tien Nguyen on Sun Jan 23 21:45:35 EST 2005
  ·  Next Article by George Pople on Wed Oct 06 09:14:23 EDT 2004
    ·  I heavily second this! by Luc Fueston on Thu Oct 07 02:39:30 EDT 2004
      ·  I heavily second this! by Szoke Szoke on Mon Oct 11 07:54:51 EDT 2004
        ·  I heavily second this! by jim bodine on Tue Dec 14 18:19:18 EST 2004
          ·  I heavily second this! by Marcel Havekes on Mon Feb 28 06:50:59 EST 2005
  ·  What Assembly to use? by Mark Monster on Tue Dec 21 02:59:03 EST 2004
  ·  Introducing NHibernate by Kiran Kumar on Thu Mar 10 04:12:00 EST 2005
  ·  NHibernate Wiki is up! by Peter Smulovics on Tue Apr 05 03:46:58 EDT 2005
  ·  How to Have Multiple XML Mapping for Same Class? by Damon Carr on Sat Sep 09 14:31:33 EDT 2006
  Message #133958 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Bryan Murphy on August 12, 2004 in response to Message #133947
Interesting! And I just started experimenting with Hibernate at home to see how much I liked it. I feel a need for an O/R mapping framework at my day job, and until now I haven't seen anything I liked.

I still do not like the Hibernate XML mapping format. It's not that it's XML, it's more that it's not as clear as I think it could be. Regardless, this might just be the tool I've been looking for!

Bryan

  Message #133964 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: javier castanon on August 12, 2004 in response to Message #133958
I still do not like the Hibernate XML mapping format. It's not that it's XML, it's more that it's not as clear as I think it could be.
Whoa! Why do you think it's not clear? It's generally accepted that that XML mapping format is so clean that you don't even need a GUI tool in order to edit it.

  Message #133983 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: McCorney Severin on August 12, 2004 in response to Message #133964
I am so excited about this port, I can't contain myself. On my last project, I built an or/mapper from the ground up. Using, offcourse, xml medata data mapping and domain objects replete with QueryObject. This follows the pattern listed in fowler. I had great success with it. However, when you start dealing with many-many and one-many relationships, your codes starts to get hairy. It is still doable, however, having an out of the box framework for doing so is ideal. I am actually testing nhibernate now for my current project.

-M

  Message #133988 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Jon King on August 12, 2004 in response to Message #133964
I still do not like the Hibernate XML mapping format. It's not that it's XML, it's more that it's not as clear as I think it could be.
Hibernate XML mapping format is the clearest I have come across, what would you change ?

  Message #134010 Post reply Post reply Post reply Go to top Go to top Go to top

1:1 M:1 lazy loading?

Posted by: Deyan Petrov on August 13, 2004 in response to Message #133947
Does it allow lazy-loading of 1:1 and M:1 relationships? For example UniversityClass - Professor (Professor member is lazy-loaded) if I use the example in the article?

  Message #134047 Post reply Post reply Post reply Go to top Go to top Go to top

What are its features status compare to Hbernate

Posted by: arun sahni on August 13, 2004 in response to Message #134010
What fetures are supported by NHibernate compare to original Hibernate? has anybody used NHibernate in production environment?

  Message #134057 Post reply Post reply Post reply Go to top Go to top Go to top

1:1 M:1 lazy loading?

Posted by: bob farmer on August 13, 2004 in response to Message #134010
Yes.

  Message #134061 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: John Harby on August 13, 2004 in response to Message #133947
I think this was a great idea. Since there are fewer competitors on the .Net side it will probably be an even greater success.

  Message #134098 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Mike Griffin on August 13, 2004 in response to Message #133958
We have folks using our product in conjuction with it (as they have told me) but I guess it's time to check it out.

Mike Griffin
http://www.mygenerationsoftware.com

  Message #134157 Post reply Post reply Post reply Go to top Go to top Go to top

Yes, it does

Posted by: Justin Gehtland on August 14, 2004 in response to Message #134010
And I'll be addressing it in part 2 next month. ;-)

  Message #134350 Post reply Post reply Post reply Go to top Go to top Go to top

Other persistence frameworks

Posted by: Fernando Rodriguez on August 17, 2004 in response to Message #133947
Besides NHibernate, there are more persistence frameworks in C#:
http://csharp-source.net/open-source/persistence

  Message #134400 Post reply Post reply Post reply Go to top Go to top Go to top

Are public properties really needed?

Posted by: Patrick Heymans on August 17, 2004 in response to Message #133947
Nice article, which was very useful, but one thing is not correct:

"Of course, you’ll need to expose these data fields through public properties, not only for use by your other classes but by NHibernate as well. NHibernate uses reflection to access the properties of your persistent classes, and just like any other .NET library, it can’t access private fields of your classes."

As far as I know, you can access private fields using reflection. I've tried another persistence framework (Gentle.Net) that supports this, but I am not sure if NHibernate does.

  Message #134402 Post reply Post reply Post reply Go to top Go to top Go to top

re: Other persistence frameworks

Posted by: Fabrice Marguerie on August 17, 2004 in response to Message #134350
In fact there are a lot of object-relational mapping (30+) and persistence (40+) tools.

  Message #134478 Post reply Post reply Post reply Go to top Go to top Go to top

That was an error

Posted by: Justin Gehtland on August 17, 2004 in response to Message #134400
That paragraph was all messed up. There are some corrections being posted to the article today or tomorrow (as soon as editing gets through with them) and this is one of them. Thanks for catching it, though!

  Message #134516 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Surendra Jambe on August 17, 2004 in response to Message #133988
I still do not like the Hibernate XML mapping format. It's not that it's XML, it's more that it's not as clear as I think it could be.
Hibernate XML mapping format is the clearest I have come across, what would you change ?
I tend to agree with first comment that XML Mapping format is not very clear.
One e.g.
<class name="nhRegistration.Department, nhRegistration"
  table="department">

</class>
Here the attribute, 'name' has 2 meanings, which is ambiguous. First is fully qualified name and second for assembly name. At the first glance of this, it is not clear purpose of 2 values for name attribute and use of it. One need to remember that first is qualified name and second for assembly.
This can be easily represented as
<class fullyQualifiedName="nhRegistration.Department" assemblyName="nhRegistration"
  table="department">
</class>
Above schema does not keep any room for ambiguity.
Like this there could be more e.g. for Config schema
My 2 cents...
Thx,
Surendra

  Message #134567 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Patrick Heymans on August 18, 2004 in response to Message #134516
I tend to agree with first comment that XML Mapping format is not very clear.One e.g.<class name="nhRegistration.Department, nhRegistration"   table="department"></class>Here the attribute, 'name' has 2 meanings, which is ambiguous. First is fully qualified name and second for assembly name. At the first glance of this, it is not clear purpose of 2 values for name attribute and use of it. One need to remember that first is qualified name and second for assembly.
The pattern being used by NHibernate for identifying class types is exactly how .NET does, so I don't see any problems. For details see Type.GetType(sting).

Pat

  Message #134625 Post reply Post reply Post reply Go to top Go to top Go to top

Not 100% sold

Posted by: Doug Adams on August 18, 2004 in response to Message #133947
I have used hibernate on two smaller java projects, and was on the whole happy.

However, my next project is .NET and a larger scale project. I dont know if I am happy to use Hibernate for this. It seems to me that with these object mapping frameworks you need to execute some kind of sql, or messing about with some kind of exceptional situation and once you are using the framework its awkward to get round it without making your code more awkward to read.

Only my experience though :)

  Message #135035 Post reply Post reply Post reply Go to top Go to top Go to top

Check your exception handling

Posted by: Ingemar Lundberg on August 20, 2004 in response to Message #133947
Interesting article and technology indeed.

I just want to comment on the try-catch handling in the sample code.
ISession session;
ITransaction tx;

try
{
session = factory.OpenSession();
tx = session.BeginTransaction();
// do database work
tx.Commit();
session.Close();
}
catch (Exception ex)
{
tx.Rollback();
session.Close();
// further exception handling
}

I can’t claim to know the inner workings of OpenSession but if there’s a chance it throws and surfaces an exception, the catch is going to access a null reference, tx. General advice:

Acquire Resource;
Try
Do Something with Resource
Catch
Do something
Finally
Release Resource

Actually there’s a semantic implication of OpenSession. To me it should either return a valid ISession reference to an open reference or it should throw an exception. The same goes for BeginTransaction. So, IMHO this is how to write it (my 2c):

ISession session = factory.OpenSession();
try
{
  ITransaction tx = session.BeginTransaction();
  try
  {
    // do db work
    tx.Commit();
  }
  catch
  {
    tx.Rollback();
  }
}
finally
{
  session.Close();
}

Both session in finally and tx in catch will be valid references provided that OpenSession and BeginTransaction returns what they atomically should return, i.e. an open session in the former case and a started transaction in the latter case.

(How the other sample, the one with session and tx declared in the try branch, compiles is a mystery. tx and session is out of scope in the catch branch. But that is beside the point.)

Best regards, all in good will,
Ingo

  Message #135616 Post reply Post reply Post reply Go to top Go to top Go to top

Int32 cannot be used as Identity Key?

Posted by: Daniel Polistchuck on August 25, 2004 in response to Message #133947
That's what I get when I try to save a Department using the example from the article:

A ValueType can not be used with IdentityKey. The thread at google has a good description about what happens with boxing and unboxing ValueTypes and why they can not be used as an IdentityKey: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=bds2rm%24ruc%241%40charly.heeg.de&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DSystem.Runtime.CompilerServices.RuntimeHelpers.GetHashCode%26sa%3DN%26tab%3Dwg Parameter name: key

Can't an Int32 be used as a PK field?

  Message #135688 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Int32 cannot be used as Identity Key?

Posted by: Szoke Szoke on August 26, 2004 in response to Message #135616
You may use int32 for your identity key, could you send your problematic hbm file and class file to szokelizer@freemail.hu ?

  Message #135689 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Introducing NHibernate

Posted by: Szoke Szoke on August 26, 2004 in response to Message #134567
Just to clarify it: FQN has the following format (from MSDN):

"
All compilers that support the common language runtime will emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.

Delimiter Meaning
Backslash (\) Escape character.
Comma (,) Precedes the Assembly name.
Plus sign (+) Precedes a nested class.
Period (.) Denotes namespace identifiers.

For example, the fully qualified name for a class might look like this:

TopNamespace.SubNameSpace.ContainingClass+NestedClass,MyAssembly

If the namespace were TopNamespace.Sub+Namespace, then the string would have to precede the plus sign (+) with an escape character (\) to prevent it from being interpreted as a nesting separator. Reflection emits this string as follows:

TopNamespace.Sub\+Namespace.ContainingClass+NestedClass,MyAssembly

A "++" becomes "\+\+", and a "\" becomes "\\".

This qualified name can be persisted and later used to load the Type. To search for and load a Type, use GetType either with the type name only or with the assembly qualified type name. GetType with the type name only will look for the Type in the caller's assembly and then in the System assembly. GetType with the assembly qualified type name will look for the Type in any assembly.

Type names may include trailing characters that denote additional information about the type, such as whether the type is a reference type, a pointer type or an array type. To retrieve the type name without these trailing characters, use t.GetElementType().ToString(), where t is the type.

Spaces are relevant in all type name components except the assembly name. In the assembly name, spaces before the ',' separator are relevant, but spaces after the ',' separator are ignored.
"

  Message #135703 Post reply Post reply Post reply Go to top Go to top Go to top

Re: What are its features status compare to Hbernate

Posted by: Szoke Szoke on August 26, 2004 in response to Message #134047
It's in a status, when it can be used.
I use it in production environment, currently having ~100 tables, ~200 classes and ~2500 properties with many components, joined components, subclasses, joined subclasses, 1:1, 1:N, N:M connections, etc...

  Message #136650 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Int32 cannot be used as Identity Key?

Posted by: Jason Davis on September 02, 2004 in response to Message #135688
I'm having the same issue. Did you ever get a response or solution? I'd be very interested. Thanks.

  Message #136955 Post reply Post reply Post reply Go to top Go to top Go to top

Re: Int32 cannot be used as Identity Key?

Posted by: Szoke Szoke on September 06, 2004 in response to Message #136650
You may use int32 for your identity key, could you send your problematic hbm file and class file to szokelizer@freemail.hu ?

  Message #141504 Post reply Post reply Post reply Go to top Go to top Go to top

Next Article

Posted by: George Pople on October 06, 2004 in response to Message #133947
When can we expect the next article to come out? I noticed that references were made to next month, but that was about two months ago. Thanks.

  Message #141692 Post reply Post reply Post reply Go to top Go to top Go to top

I heavily second this!

Posted by: Luc Fueston on October 07, 2004 in response to Message #141504
I (along with several others I know about) have implemented NHibernate successfully, and (along with the development of a very flexible Persistence layer to ensure that I can switch amongst providers at any given time) am using it in production. However, although I have a couple of books on Hibernate specifically, I've informally limited myself to using the most basic (and likely stable) subset of NHibernate's functionality. My reasoning is that while I have higher hopes for NHibernate than any other .NET solution except, eventually, ObjectSpaces -- based mostly on just how far ahead Hibernate is compared to most other options -- I personally don't have the time to test what limitations it has.

I'm finding that even with limiting myself to traditional data access patterns, the sheer amount of time saved and the sheer elegance that being able to have, for instance, a set of mappings based on interfaces and their implementers (the idea seemed backwards to me as well from a maintenance standpoint, but I set aside a portion of my object hierarchy to test the idea on and with the creation of a few memento objects I've been able to come up with some nice reductions in mapping complexity).

However, I don't have time right now to look at different methods of using the Session object and lazy loading (for instance, in a web-app) and deal with potential bugs at the fringe of the project.

The library is just enormous, and more and more work is being done on it all the time, so I am pretty sure that you'd have a huge audience for the article. Please let us know what the status is! I am very interested in some expert notions, so I can have an idea what general level of sophistry NHibernate can support without discovering for myself that I've overstepped the bounds of stability.

  Message #142183 Post reply Post reply Post reply Go to top Go to top Go to top

I heavily second this!

Posted by: Szoke Szoke on October 11, 2004 in response to Message #141692
We are currently approaching to a version 0.4.0.0, which will hopefully will contain stable proxy support (now only collection lazy load is supported) - currently this is nearly the only feature that is missing. Other parts of the framework can be designated as highly usable, but of course performance bottlenecks, feature requests from other nhibernate versions, etc, are highly welcomed.

  Message #149445 Post reply Post reply Post reply Go to top Go to top Go to top

I heavily second this!

Posted by: jim bodine on December 14, 2004 in response to Message #142183
you indiciated that your are moving to 0.4.0. i downloaded 0.5.0 and tried to set up the database and stuff from this article (nhibernate). i keep getting this error message

"NHibernate.ADOException: problem in find ---> NHibernate.PropertyAccessException: Exception occurred setter of College.CDepartment.Courses ---> System.ArgumentException: Object type cannot be converted to target type.\r\n at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)\r\n at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)\r\n at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)\r\n at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)\r\n at System.Reflection.MethodInfo.Invoke(Object obj, Object[] parameters)\r\n at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)\r\n at NHi
bernate.Property.BasicSetter.Set(Object target, Object value)\r\n --- End of inner exception stack trace ---\r\n at NHibernate.Property.BasicSetter.Set(Object target, Object value)\r\n at NHibernate.Persister.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values)\r\n at NHibernate.Impl.SessionImpl.InitializeEntity(Object obj)\r\n at NHibernate.Loader.Loader.DoFind(ISessionImplementor session, QueryParameters parameters, Object optionalObject, Object optionalID, PersistentCollection optionalCollection, Object optionalCollectionOwner, Boolean returnProxies)\r\n at NHibernate.Loader.Loader.Find(ISessionImplementor session, QueryParameters parameters, Boolean returnProxies)\r\n at NHibernate.Loader.CriteriaLoader.List(ISessionImplementor session)\r\n at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)\r\n --- End of inner exception stack trace ---\r\n at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)\r\n at NHibernate.Impl.CriteriaImpl.List()\r\n at College.f
Main.mnuDepartmentOpen_Click(Object sender, EventArgs e) in c:\\csnetprojects\\college\\fmain.cs:line 262"


i renamed univiersityclass to course

  Message #150128 Post reply Post reply Post reply Go to top Go to top Go to top

What Assembly to use?

Posted by: Mark Monster on December 21, 2004 in response to Message #133947
Hmm interesting. But I want to try it.

You say reference the assembly in your project. Which ones?
Commons.dll (probably)
DotNetMock.Core.dll (probably not)
DotNetMock.dll (probably not)
DotNetMock.Framework.dll (probably not)
HashCodeProvider.dll (probably)
Iesi.Collections.dll (probably)
log4net.dll (probably not)
NAnt.Core.dll (probably not)
NHibernate.ddl (probably)
NHibernate.DomainModel.dll (probably)
NHibernate.Examples.dll (probably not)
NHibernate.Task.dll (probably)
NHibernate.Test.dll (probably not)
nunit.framework.dll (probably not)
NVelocity.dll (probably not)

Does anyone know? I couldn't find any documentation about that. I don't think that referencing all assemblies is a good thing when we are only going to use a few.

Regards,

Mark Monster

  Message #153944 Post reply Post reply Post reply Go to top Go to top Go to top

Int32 cannot be used as Identity Key?

Posted by: Tien Nguyen on January 23, 2005 in response to Message #135616
Hi
I'm just starting NHibernate and c#, just wonder if you could share your sourcecode for this example

Cheers
Tien

  Message #158982 Post reply Post reply Post reply Go to top Go to top Go to top

I heavily second this!

Posted by: Marcel Havekes on February 28, 2005 in response to Message #149445
I've had the same problem: "Object type cannot be converted to target type".

The "Object type cannot be converted to target type" error is caused by the fact that the C# classes in the sample use the IDictionary interface and the...hbm.xml mapping files from the sample use the "<set.....> tag.
The "<set>" tag will result in the use of a nhibernate.collections.set class.
This nhibernate.collections.set class implements (via iesi.collections) the ICollection interface. NOT the IDictionary interface.

So changing IDictionary into ICollection did(in my case)help me get rid of the problem. But: it gave some other problems like not being able to read the data from the collection. Haven't had time to look into that.
(Probably the IDictionary has to go back in the C# classes and the "<set>" tag from the hbm.xml file has to replaced by ..??)

Hope it helps.





you indiciated that your are moving to 0.4.0. i downloaded 0.5.0 and tried to set up the database and stuff from this article (nhibernate). i keep getting this error message"NHibernate.ADOException: problem in find ---> NHibernate.PropertyAccessException: Exception occurred setter of College.CDepartment.Courses ---> System.ArgumentException: Object type cannot be converted to target type.
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.Reflection.MethodInfo.Invoke(Object obj, Object[] parameters)
   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
   at NHibernate.Property.BasicSetter.Set(Object target, Object value)
   --- End of inner exception stack trace ---
   at NHibernate.Property.BasicSetter.Set(Object target, Object value)
   at NHibernate.Persister.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values)
   at NHibernate.Impl.SessionImpl.InitializeEntity(Object obj)
   at NHibernate.Loader.Loader.DoFind(ISessionImplementor session, QueryParameters parameters, Object optionalObject, Object optionalID, PersistentCollection optionalCollection, Object optionalCollectionOwner, Boolean returnProxies)
   at NHibernate.Loader.Loader.Find(ISessionImplementor session, QueryParameters parameters, Boolean returnProxies)
   at NHibernate.Loader.CriteriaLoader.List(ISessionImplementor session)
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
   --- End of inner exception stack trace ---
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
   at NHibernate.Impl.CriteriaImpl.List()
   at College.fMain.mnuDepartmentOpen_Click(Object sender, EventArgs e) in c:\csnetprojects\college\fmain.cs:line 262"i renamed univiersityclass to course


  Message #160753 Post reply Post reply Post reply Go to top Go to top Go to top

Introducing NHibernate

Posted by: Kiran Kumar on March 10, 2005 in response to Message #133947
Hai ,
As i am new to Nhibernate,
can any of u guys help me in displaying the data from the table to a web page using Nhibernate

else i will put in this way

how can i do the operation like
modifying,deleting,selecting the records from the database using Nhibernate

please kindly help me regarding this


rgds
Kiran

  Message #164729 Post reply Post reply Post reply Go to top Go to top Go to top

NHibernate Wiki is up!

Posted by: Peter Smulovics on April 05, 2005 in response to Message #133947
NHibernate Wiki is up and running: http://jira.nhibernate.org/confluence/

Will contain a hole bunch of information: http://jira.nhibernate.org/confluence/pages/viewpage.action?pageId=278

Internal and external documentation, samples, code tips, etc. Feel free to contribute, ask or just browse!

  Message #172239 Post reply Post reply Post reply Go to top Go to top Go to top

Error: could not load object

Posted by: Koffer Shen on May 30, 2005 in response to Message #133958
When I attempt to load UniversityClass Data, I encounters a error.it is: could not load object
The code is as follows:
try
{
UniversityClass relateClass = (UniversityClass)aEntityRule.GetEntity(typeof(UniversityClass),3);
Response.Write(relateClass.Students.Count.ToString());
}
catch(Exception mme)
{
Response.Write(mme.Message);
}
Who can tell me why?

  Message #172245 Post reply Post reply Post reply Go to top Go to top Go to top

Could provde the sourceCode, especially the *.hbm.xml

Posted by: Koffer Shen on May 30, 2005 in response to Message #133958
Hi, Justin Gehtland :
I use NHibernate only for 2 weeks, and I found it is really a very good one. In my experience of using NHibernate, I use the one-to-many or many-to-many relationship between classes. Just as the release notes say, the relationship can load the date automatically, but I encounter a error at the "save" function called.
The error in stack is :
 at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything).

The sample code:
Department aDepartment = new Department();
aDepartment.deptname = "Computer Science";

aEntityRule.Save(aDepartment);

  Message #217580 Post reply Post reply Post reply Go to top Go to top Go to top

How to Have Multiple XML Mapping for Same Class?

Posted by: Damon Carr on September 09, 2006 in response to Message #133947
I have multiple database tables which I want to map in multiple XML files to the same Business Object.

Is this possible?

For example, I have a class which is a kind of 'NameValueCollection'. I also have a number of tables where I want to populate a collection of NameValueCollection instances with the ID and Display from various columns in these tables.


Thanks,
Damon

 
New content on TheServerSide.NETNew content on TheServerSide.NETNew content on TheServerSide.NET

DSLs and language interop

Language "mashups" will become more prominent, and developers will become polyglots, one programmer suggests.

VS 2008 Resources

SearchWinDevelopment.com offers an introduction to the language, performance, testing and data management improvements in VS 2008.

VB code downloads home

VBCode.com code snippets cover all aspects of application development, from data binding to security to the user interface.

XAML Learning Guide

Get up to date on XAML best practices with a variety of articles, tutorials and webcasts. [SearchWinDevelopment.com]

Company uses VSTS DB edition to tame workflow

One team's experience with the VSTS DB edition suggests that it can improve workflow for dev teams. It also enhanced Agile efforts. (June 24, Article)

Book: Intro to DSL Tools

Microsoft has begun to include DSL tools in the VSTS kit. A new book by Steve Cook and other VSTS team members helps set the stage. (June 24, Article)

I See the Silverlight Shining!

Cartoon: Be it ever so humble there is no place like your home after you get a Microsoft Home Server . (June 18, Cartoon)

A look at .NET 3.5

Microsoft's Thom Robbins says new technology to highlight in NET 3.5 includes AJAX, LINQ for both C# and VB, as well as tooling enhancements intended to ease the task of building WPF, WF and WCF apps. (June 29, Podcast)

Venkat Subramaniam on AJAX

Venkat Subramaniam discusses AJAX bottlenecks, the tenets of Agile development and more. He spoke at the Ajax Experience. (June 25, Tech Talk)

Building a Claims-Based Security Model in WCF - Part 2

In the second of a two-part series, Michele Leroux Bustamente discusses design decisions related to the claims-based security model. Read the story and walk through the process for creating a set of claims-based utilities to encapsulate claims authorization at the service tier. (May 24, Article)

Introducing the Entity Framework

Understanding why the Entity Framework exists and learning where it can fit into your projects can get you prepared for the eventual release early next year. (May 10, Article)

WCF Security Learning Guide

Resource: This learning guide gives you quick access to useful links on Windows Communication Foundation security information. (April 24, Article)

Brad Abrams: Patterns for successful ASP.NET AJAX development

TSS.NET's Jack Vaughan spoke recently spoke with Microsoft's Brad Abrams to find out what he is seeing in the field and what the chefs in Redmond are cooking. Along the way he discusses patterns of AJAX frameworks. (April 11, Article)

Building a Claims-Based Security Model in WCF

In a two-part series, Michele Leroux Bustamente explains how claims-based security is supported by WCF, and how you can implement a claims-based security model for your services. (March 29, Article)

Authoring workflow using XAML

Windows Workflow Foundation is a new technology that many developers will need to get their heads around. In a brief excerpt adapted from Programming Windows Workflow Foundation: Practical WF Techniques and Examples using XAML and C#, K.Scott Allen considers aspects of workflow definition. (March 22, Chapter Excerpt)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map