I have a legacy DB which uses a guid to map children to the parent entity.
In my domain layer, I'd prefer to obscure this quirk, so I'd like to have my parent entity look like this:
public class Parent
{
virtual public int Id {get; protected set; }
virtual public string ParentContent { get; set; }
virtual public Guid Refer...
I'm reasonably new to NHibernate and everything has been going pretty well so far but I've come across a problem I'm not exactly sure of how to go about solving. Basically I need to filter by the output of a User Defined function. If I was writing in SQL this is what I'd write:
declare @Latitude decimal
declare @Longitude decimal
declar...
I'm trying to map inheritance with discriminator, but subclasses don't have discriminator value. How to solve it using AutoMappings?
Domain objects are as following:
public abstract class Item : GuidIdentityEntity {
public virtual string Name { get; set; }
}
public class Product : Item {}
public class RawMaterial : Item {}
Config...
I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new?
I am thinking I might create a session interceptor to force every entity to look new and ensure the id is left blank like a new unpresisted entity would.
...
I am using NHibernate against a legacy database which uses Char column types (fixed Strings). I am mapping the char columns to strings in properties. Currently my criteria queries are failing if the value against which i am querying is not padded with spaces such that the length of the string is equal to the char column length. I dont wa...
How do I set the batch size for Nhibernate? I'd like to do this in the web.config. The examples I see, don't make a lot of sense to me.
In this example they are using code to set the batch size. I don't wnat to do that. I want it configurable in the web.config.
I understand how to add the config section, I just have read articles t...
Hi,
I am trying to implement a "if exists, update, otherwise, insert" data access method in NHibernate. My database is Oracle 10g.
I am getting this "could not execute native bulk manipulation query" error when try to run this code, if I run the insert or update individualy, it works just fine.
Thanks!
string sql = @"DECLARE
...
Hi,
I am using Fluent NHibernate to do my NHibernate mappings, but now I have come to a problem that I am not sure how to solve. A simplified version of the problem follows.
I have a user class:
public class User {
public virtual int Id { get; set; }
public virtual string FirstName { get; set; }
public virtual string Last...
Hello guys...
I have a class Client like that:
public class Client{
public Person Pers { get; set; }
}
And I have 2 Person´s child class :
public class PersonType1 : Person {...}
public class PersonType2 : Person {...}
Now I loaded a client... And I need to get the PersonType1 or PersonType2 attributes ..
I tried that:
var _p...
Hi all,
I was wondering if there is any way to lazy load part of map in NH?
Here is my mapping:
<map name="Resources" table="COUNTRY_TL" fetch="subselect">
<cache region="CountryCache" usage="read-write" include="all"/>
<key column="COUNTRY_ID"/>
<index column="LANGUAGE_CODE" type="System.String"></index>
<composite-element cl...
I have an object mapped as follows:
<class name="A" table="TableA">
<id name="ID" column="AId" type="Int32" unsaved-value="0">
<generator class="native" />
</id>
<discriminator column="Type" type="Int32" />
<property name="Description" />
</class>
<subclass name="B" discriminator-value="0" extends="A">
<prop...
This is a pretty fundamental question when using NHibernate in a web application, but I don't see any agreed best practice when searching the web. I've seen it done in lots of different places:
Created and disposed in the Repository method - This just seems silly to me, since when you get the object it's already detached.
At the begin...
I am having a little trouble with building my criteria object. Normally, I Build my cruteria similarly to this:
ISession session = GetSession();
ICriteria criteria = session.CreateCriteria(typeof(MyObject))
.Add(Expression.Gt("StartDate", DateTime.Now.ToUniversalTime()))
.Add(Expression.Eq("SubObject.Sub...
We use two databases in our web-application. One is located in USA and one is in Canada. You should see only the data based on your country. Now I think there will be a problem when it comes to create the SessionFactory objects, because the entities were already created for USA. Now when nHibernate tries to create the factory for the CAN...
Consider an entity, Entry, that contains a collection of another entity (many-to-many), Category, such that the Entry can be associated with a given Category no more than once (implying a "set" and constrained by the database) and the ordering of the Category entities within the collection is fixed and is defined by an extra field on the...
While playing around with one-to-one associations in castle activerecord I stumbled upon the following problem:
I'm trying to model a one-to-one relationship (user-userprofile in this case). I already learned that this may not be a best practice, but let's ignore that for a moment (I'm still trying to understand what's going on).
[Acti...
I'm trying to work through the "Your first NHibernate based application" to get the hang of other types of ORMs (I'm used to DevExpress' XPO) and I understand that there is a difference between the version that the tut uses and the newest available version.
When I try to run the can_add_new_product test I get the error that titles this ...
I'm trying to write a Compare method to compare properties in some POCOs using Reflection to ensure that they've been persisted to the database correctly. For example, let's say I have this POCO:
public class NoahsArk
{
public string Owner { get; set; }
public ICollection<Animal> Animals { get; set; }
}
What I want to do is th...
I've already read http://stackoverflow.com/questions/478296/nhibernate-changing-sub-types and I don't find that satisfactory to my situation.
My system allows users to schedule jobs. Schedules can be set up with different types of schedule criteria (Once only, Daily, Weekly, Monthly by day of month, and Monthly by week of month). Each...
I'm getting an NHibernate.DuplicateMappingException that I don't understand. The app is a simple project manager. It contains a Project class, which has a Notes property of type ProjectNote. Here is the error message:
NHibernate.MappingException: Could not compile the mapping document: ProjectManager.Domain.Mapping.ProjectNote.hbm.xml -...