The ISession.Find()... methods are now deprecated. Does the statement about NH guaranteeing the Find()... methods will not return stale or incorrect data extend to ICriteria based queries? See this post for reference.
...
If I call Save on a new object, then populate its properties, NHibernate generates and insert statement that contains only the default values for the properties. For example (session is an open ISession):
var homer = new Person();
session.Save(homer);
homer.Name = "Homer J. Simpson";
session.Flush();
I thought that calling Save would ...
I keep encountering the following error when using NHibernate.Linq
System.NullReferenceException: Object reference not set to an instance of an object.
at NHibernate.Linq.Visitors.AssociationVisitor..ctor(ISessionFactoryImplementor sessionFactory)
at NHibernate.Linq.NHibernateQueryProvider.TranslateExpression(Expression expression)
at N...
I have three objects.
public class ParentClass
{
public virtual Guid ParentClassId { get; set; }
public virtual IList<Child> Children { get; set; }
}
public class Child
{
public virtual Guid ChildId { get; set; }
public virtual ParentClass Parent { get; set; }
}
public class Record
{
public virtual Guid RecordId { get; set; }
public v...
Hi. The design I'll describe violates somehow good practices design but still I'm interested in why this issue appears and how it can be bypassed. I found some description of problems that can occur using NHibernate and Update or Select triggers however I could find nowhere the problem I face.
I have a table and class mapped to it calle...
I'm currently learning NHibernate and I would like to data-bind to Web controls (i.e. GridView).
In my current example I am using Fluent NHibernate to map two tables to their business objects (Project and ProjectStatus). I also have a "Project has a ProjectStatus" (many-to-one) relationship.
Structure of Project class:
Project.ID
Proj...
I have an existing POCO class library where children collections are all stored in arrays. For instance, the Customer class has a Invoice[] array to hold its invoices:
class Customer
{
public int ID;
public Invoice[] _invoices;
}
class Invoice
{
public int ID;
public int CustomerID;
public string SomeData;
}
I can...
I am trying to get the following query to work:
Session.Linq<FooBar>()
.SetCachable(true)
.SetCacheRegion("foobar")
.Select(x => new Baz(x.Foo, x.Bar))
.ToList();
This works when caching is turned off, but with caching enabled I
receive the following exception:
System.InvalidCastException: Unable to cast object of typ...
I have two applications running on a machine, where NHibernate is used as an ORM. One app is managing objects (CRUD operations), while the other is processing the objects (get, process, set status and save).
First I let the processing app process an object and set the status to processed. Then I change a text property manually in the da...
I have my NHibernate configuration successfully set up in my web.config file. However, I am also using ASP.NET Membership which requires a connectionstring to be defined in the connectionStrings element. Is there a way I can make my NHibernate configuration use this value so I don't need to define the connection string twice?
TIA!
...
I have read in Chapter 4 of the NHibernate docs that all of a persistent classes public methods, properties and events must be declared as virtual.
However, whilst a runtime error is generated for any Properties that are not marked as virtual, I have found that static methods are allowed and do not generate a runtime error . As they are...
I'm implementing a custom EventListener to save auditing information in NHibernate.
I'm currently extending DefaultSaveOrUpdateEventListener, overriding PerformSaveOrUpdate, going through the properties of each entity and saving them elsewhere.
This works with simple properties, but fails when cascade-saving a one-to-many relationship....
I have a base class for content items in a CMS I'm building. It's currently marked abstract because I only want derived classes to be instantiated. Derived classes like BlogPost, Article, Photo, etc. are set up as a joined subclass to my ContentBase class in nHibernate.
I'm trying to set up a many-to-many mapping between this class an...
I have a criteria query that I am using to show pages of results. I also need to obtain the total count of all items. Rather than have two queries, one for paging the results and one for the count (since they are identical apart from the .AddOrder()
public ICriteria StandardQuery {
get {
return NHibernateSesssionManager.Ge...
I started creating a domain model and now I asking myself, how can I map this domain model to a NHibernate Data Model ((using Fluent NHibernate)? Is there anywhere a good and simple example of how to do that?
With Data Model I didn't think about the physical/relational Database Model(!) What I meant was the Data Model in the Data Access...
In NHibernate Profiler I observed that when I use eager fetching on an association, using "left join fetch" in an HQL Query or .SetFetchMode() in a Criteria Query the query no longer gets cached in the query cache.
In fact from what I can see only very basic queries are cached. If anyone can give me some insight into what queries get c...
I have a DomainObject with a property
List<DomainObject> Connections{get;set;}
So each object can be "connected" with others and I have to save this information in db to restore the entire graph on demand.
Now I have a string property with the CSV of all Ids of DomainObject inside the Connections property but i'm not happy...
There'...
How can I write the following SQL using CreateCriteria:
SELECT * FROM FooBar fb
WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id)
...
I have a Person entity belongs to a person has a Country, I want to select all the distinct countries that have people in them. Easy in HQL
select distinct p.Country from Person p
How can I do this using a Criteria Query?
...
Hi Everyone,
I have a Nhibernate Repository which I use with a Object DataSource to bind Job Objects (shown below) to various controls on a Asp.Net page.
So far I've not had any problems binding, until I wanted to bind the inner IList of Tasks contained in the Job Object:
Specifically I want to bind the Tasks list to a Gridview, So ...