Is it possible to do a mapping in NHibernate without using an Id?
What I'm trying to do is, call a stored procedure using
session.CreateSqlQuery( myQuery ).AddEntity( typeof( MyEntity ) );
The procedure is an aggregate and there is no Id field being returned, but I would still like to take advantage of NHibernate mapping the data re...
Hey all,
I am working with a legacy database that uses composite keys. And I am trying to use NHibernate to insert a new record into the database. NHibernate specifies that I have to create the Id manually, but when I try to insert with this id I get the message:
System.Data.SqlClient.SqlException: Cannot insert explicit value for iden...
I have mapped the following collection:
<list name="Media" table="AlbumMedia">
<key column="Album_id" />
<index column="Position" />
<composite-element class="AlbumMedia>
<parent name="Album" />
<many-to-one name="Media" column="Media_id" />
</composite-element>
</list>
I need to find the index of an element within thi...
I could not find any query.executeUpdate() method in IQuery interface or ISession where i can pass an hql to update a record.
here is the hql:
string hql = "update QAD qa set qa.NFS=:NFS where qa.ID = 1145";
IQuery q = session.CreateQuery(hql).SetString("NFS", "10");
...
Hello All,
I am new to NHibernate.I created a database in my sqlserver and want to export the schema using Nhibernate in c#.I have two classes called Customer and Address.
customer.cs
public class Customer
{
public int ID
{get;
set;}
public Address Address1
{
get;
set;
}
public Address Address2{get;set;}
}
Address.cs
public class Addre...
I have a set of tables that look like the following:
Person - PersonID, FirstName, LastName, etc...
Family - FamilyID, etc...
Parent - PersonID, FamilyID, etc...
Child - PersonID, FamilyID, etc...
Contact- PersonID, etc...
My object hierarchy is organized as follows (using c#):
class Person
class Family
interface IFamilyMember
class...
So, newbie NHibernate user; trying to wrap my brain around it.
I'm contemplating how to handle deployment, and later injection of add-ons to a web app (which may require their own persistence classes).
I was thinking that using SchemaExport for the deployment would work pretty well, but I was wondering if there's a way too get NHiberna...
I have an Ms Access view(query) as following
select * from employee Where EmployeeId=SomeID
Here SomeId is not a field name
If I run this query from MsAccess
It prompts me for entering value for SomeId as follows
|---------------------------------------|
| Enter Parameter Value X |
|-----------------------------------...
Hi!
I've got a generic ASP.NET (MVC) application, that uses NHibernate as the model persistence layer, and ASP.NET Membership/role/profile services as the user management layer.
The question is what can be considered as the best practice to create linkings between the domain data and the users. (For example is I want to create a forum ...
I have a simple example; a concrete class that inherits an abstract generic class that implements an interface.
ie. StringProperty -> AbstractProperty<T> -> IProperty
I get the following error...
NHibernate.MappingException: These classes referenced by 'extends' were not found:
NhibernateTest.AbstractGenericProperty`1[[System.String, ...
Hi All
Can anybody tell me how to map enum in nhibernate using vb.net.When i search the google i found all samples in c# but i want vb.net(i am new to vb.net)
Thanks
...
Doman:
class Action
Products: IList of class ActionProducts:
Category: class Category
Products: IList of class Product
Now, I want this:
var products = from a in Session.Linq<Action>()
from ap in a.Products
from p in ap.Category.Products
where a.Name == n...
I know the basic ways to avoid the N+1 selects problem in Hibernate/NHibernate, but have run into a variant of the problem that I can't find a good solution to.
I have the following three entities mapped: Item, Category and Customer. An item is associated many-to-many to Category, and a Category is mapped many-to-one to Customer. So far...
I'm trying to use NHibernate (and FluentNHibernate) over a legacy database.
I'm also using SQLite for tests.
When I try to create a test for the mappings using FluentNHibernate's PersistenceSpecification, I get the following exception:
NHibernate.Exceptions.GenericADOException : could not fetch initial value for increment generator
I'...
Hi,
I was just wondering about some CodeWarning (ConstructorsShouldNotCallBaseClassVirtualMethods), and if there is a better way to do it. I have a simple log collector class, and I am using NHibernate to retrieve some of the objects.
Some times I create objects by myself (of course) and add them to NHibernate for persistance. What is t...
In my application at the moment I have (as in so many other applications) an entity called Contact, which represents any person. At its most basic level this is used to represent business contacts. However it can also be used to represent employees of the company. and there are also a couple of special types of employee (let say there is...
Hello,
I seem to be having trouble modeling inherited classes using JoinedSubClassPart in Fluent NHibernate (release 524). I have seen other posts indicating that the approach I am using (see below) should work, yet at runtime I get the following exception (thrown by ImappingPart.PositionOnDocument method of JoinedSubClassPart):
XunitE...
Hi!
I want to create a convention for column names using Fluent NHibernate auto mapping. There is a blog entry that states that property conventions can be set like this:
ConventionBuilder.Property.When(
x => x.Property.PropertyType == typeof(int),
x => x.ColumnName(x.Property.Name + "Num")
)
But the problem is, that x only has a...
Hi,
What's the recommended way of updating an entity? So far, I figured out two ways:
Just create a new entity with the existing Id and updated property values, and use session.SaveOrUpdate()
Use a DTO, retrieve the existing entity using session.Load(dto.Id), assign new vaues from the dto, then save.
No1 requires much less effort, b...
I have the following code (simplified for the sake of discussion). What I don't understand is why the session.Transaction property returns a different transaction after a rollback.
For instance, this means that the property Session.Transaction.WasRolledBack is of little help unless I store a reference to the first transaction and check...