Should a lazy loaded collection in NHibernate ever give me a NullReferenceException? I'm getting an exception in a method like the following:
public void Test(ISession session, int id)
{
var entity = session.Load<MyEntity>(id);
entity.LazyLoadedCollection.Add(SomeItem);
}
The call to LazyLoadedCollection is throwing. My mappi...
I have an entity which has a property that does not get its value from the entity's table. But it could be calculated by a query if it is possible.
To clarify, I have an entity of an Entry and I want to check if the current user voted it or not. So for that reason I thought that I could add a property like "IsCurrentUserVoted" to the E...
I'm writting an ASP.NET MVC e-commerce app using NHibernate and I want the end-user to be able to control the ordering of Product Categories (not just have them appear alphebetically etc.).
Normally, I'd add an OrderIndex/Sort column (of type int) to the Category table, and property to the Category domain class. But the problem is in ha...
I'm mixing table mapping strategies to store a class hierarchy via NHibernate 2.1.2. I'm not using Fluent NHibernate.
I understand how to map a table-per-hierarchy -> table-per-subclass structure, but not the other way around, as the XML is invalid after adding the discriminator.
Here's the HBM extract:
<class name="Base1" table="Ba...
I've seen there is a plenty of them. NCache, Velocity and so forth but I haven't found a table comparing them.
What's the best considering the following criterias:
Easy to understand.
Is being maintained lately.
Is free or has a good enough free version.
Works.
...
I am using NHibernate (v 2.1.0.4000) and try to use an event Listener for an update action.
I used the following code to add a listener to the Nhibernate Configuration.
var configuration = new Configuration();
configuration.SetListener(ListenerType.Update, new UpdateListener());
_sessionFactory = configuration.BuildSessionFactory...
Hello
Given the following tables, I am trying to return all Allocations for a given Resource's that fall between a given range of dates using a criteria query:
create table Resources (
ResourceId integer,
ResourceName TEXT not null,
BusinessId TEXT not null,
OrganizationName TEXT not null,
primary key (ResourceId)
)
c...
Hi
I have two Domain Objects mapped right : Emails and ActionPlans
the table structure is something like:
create table emails(id int identity(1,1), subject nvarchar(512), parentEmailId int, rootEmailId int)
create table actionPlans(id int identity(1,1), dueDate datetime, emailId int)
insert into emails(subject, parentEmailId, rootE...
NHibernate question:
Say I have a SQL table Person and it has a Picture column ( OLE Object ) . I have a class Person and it has : byte[] Picture attribute.
Is it possible to map like this ?
<property name = "Picture" column = "Picture" type = "System.Byte[]" lazy="true" />
Does the "lazy" keyword have any effect on properties ...
I am using Expression.In() as a part of a criteria using NHibernate and for the life of me I can't find any way to make it ignore case. Does anyone know how this can be done or am I going to have to do this a different way?
Not that it probably matters much but here is a sample of how I am using the Expression.In()
ICriteria criteria ...
I am trying to save entity data into separate table (serialized as a collection of key-value pairs).
Seams that I cannot use BeginTransaction and Commit because I am getting NHibernate ERROR
"Possible nonthreadsafe access to session"
I am not an expert of of NHib but suppose the problem is that there is already some transaction started ...
Hi guys,
I'm quite new to the whole concept of ORM, NHibernate and FluentNH, and i'm trying to accomplish something that seems so simple...
I'm trying to retrieve an object that has a field defined as Int64 in it's class. This field would be the ID, as defined in the Map file.
When trying to retrieve a record from the DB, NHibernate r...
I have a test console app that is executing sql scripts to create a database and its tables, then inserting data. I use DAO to create, retrieve, update, and delete from the tables and then try and drop the database, but it can't because it says it is currently in use. How do I kill the connection? Through debugging and running a sql scri...
Please can someone explain in english what the following code does?
var subCriteria = DetachedCriteria.For<UserLocation>();
subCriteria.SetProjection(Projections.Property("LocationId"))
.Add(Restrictions.Eq("UserId", userId));
return UoW.Session.CreateCriteria(typeof(Location))
.Add(Subqueries.PropertyIn("LocationId"...
I'm using NHibernate to communicate with the database in my C# .NET project. When communicating with the database - do I always have to commit the transaction? What does this actually do when doing reads? I find myself forgetting to commit occasionally when doing reads, but everything seems to work fine.
using (var tx = Session.BeginTr...
Is it possible to return an entity using a projection query?
I've successfully done it with a SQL query (see below), but can't find how to do it with a projection query.
Dim sql As String = "SELECT {a.*}, {b.*} FROM a LEFT OUTER JOIN b ON a.pk = b.fk")
' Convert SQL results into entities {a} and {b}
Dim query As IQuery = session.Creat...
Are there any good alternative to NHibernate's xml mappings?
I have seen Fluent. All I look for is high maintainability.
UPDATE : I would like to know the performance issues related with using fluent because I guess it is going to create xml mappings from the class (which can be time consuming - my guess)
Thanks
...
I'm trying to map the Northwind Employee entity with NHibernate:
public class Employee
{
public virtual int ObjectID { get; set; }
public virtual string LastName { get; set; }
public virtual string FirstName { get; set; }
public virtual string Title { get; set; }
public virtual string TitleOfCourtesy { get; set; }
...
Hi,
Im trying to write an NHibernate criteria that effectively joins and restricts at the same time. My DB looks like this...
Cases ---> CustomerProducts <--- Customers
Cases ---> CaseStatuses
Each case is associated with a customer product (Many cases to one product).
Each customer has a number of customer products (One customer has...
I've recently started using NHibernate, and on the whole like it a lot.
Until I ran into a problem with needing to serialize to XML and back.
I have a class that has a many to many relationship, so have an IList in the parent class to hold the list of child objects.
Class parentClass{
IList<childClass> childList;
string varA;
s...