I have the following database tables. Primary keys are ID and AnimalType.Type is a unique string.
Animal
- ID
- Name
- TypeID
AnimalType
- ID
- Type [Herbivore, Carnivore]
My classes are as follows.
public class Animal
{
public int ID { get; private set; }
public string Name { get; set; }
public AnimalType Type { get;...
I'm trying to filter by a list of values using the criteria API. I suspect that this is not possible, I'm just asking here to be sure.
class Entity
{
int id { get; set; }
IList<Guid> Guids { get; set; }
}
The mapping:
<class name="Entity">
<id ...></id>
<bag name="Guids" table="Entity_Guids">
<key column="Entity_FK"/>
...
Hi
I have this query:
criteria = session.CreateCriteria(typeof (Building))
.CreateAlias("Estate", "estate")
.SetProjection(Projections.ProjectionList()
.Add(Property.ForName("Name"), "BuildingName")
.Add(Property.ForName("estate.Name"), "EstateName")
.Add(Proj...
I'm having some trouble understanding a bit of code. I've got 2 classes Company and CompanyLocation. Mapped as:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Core.DataTransfer.CompanyLocation,Core.DataTransfer" table="`CompanyLocation`" lazy="true">
<id name="CompanyLoca...
Hi all,
Starting up a new project it is 100% new development against a very large (300 tables) legacy database. The database does not match up all that well to the business model so my initial thoughts where to use a ORM.
I got a proof of concept working with NHibernate pretty well... but got A LOT of management push back on the use ...
I'm starting to play with NHibernate to make a case for its use in our company's projects. I've created a branch of one of our solutions and have started to convert some of the data access to using NHibernate as a proof-of-concept. However, while looking at SQL Profiler, I discovered that NHibernate is issuing an update command to the d...
Hi all,
I am using NHibernate to as the Data Access layer for my ASP.NET MVC application. I am also using Structure Map as an IoC container. I have configured Structre map to create a session factory as a singleton and create sessions on a per request basis (InstanceScope.Hybrid). I am able to do basic CRUD operations just fine.
Now, I ...
If I've gotten a persistent object from the database via NHibernate's Get() or Load() methods, is there a way for me to detach that object from its NHibernate session so that changes to it will not automatically be persisted?
...
Hi
I have two tables which looks something like this
Table Queue
int ID;
string Name;
int MessageID;
string To
string From
string Topic
string Email
Table Message
int ID
int MessageType
This is a rather simplified version, but what we did in the classes was to create 1 class named
class Queue
int ID
string Name
Message...
"I am getting a weird error when using NHibernate. And I don't know what is causing this error.
I am new to the whole Visual Studio and NHibernate, but not to Hibernate. I used Hibernate in the past in Java projects.
Any help would be appreciated in pointing me where my error is.
I am using Visual Studio 2008 SP1 with Mysql 5.1.
Below...
I have been trying to get to grips with Hibernate's inverse attribute, and it seems to be just one of those things that is conceptually difficult.
The gist that I get is that when you have a parent entity (e.g. Parent) that has a collection of Child objects using a one-to-many mapping, setting inverse=true on the mapping tells Hibernat...
Hi!
Please, I'm trying to map many-to-many association in order to use cascading Delete.
Model Description: A View contains a List of Group (using the DB Association Table Asso_Project_Manager_Group_View). And a Group contains a List of Project Manager (using the DB Association Table Asso_Project_Manager_Group).
Find DB Schema Image H...
Hi all,
I am creating an asp.net mvc web site and I need an advice. I have following layers:
database
data access layer (domain objects, DAO interfaces + DAO implementations based on a NHibernate)
service layer (service interfaces + service implementations)
presentation layer (ASP.NET MVC)
There are actually several databases:
one...
Is it possible to just do some sort of type conversion and map directly to System.Drawing.Color? I'm storing the colors as html/css values. i.e. #ffffff. I don't want to have to create a custom type that implements IUserType, that is just a wrapper for System.Drawing.Color.
...
I'm trying to group table values by date, and this HQL query works fine:
SELECT af.SubmitedDate, COUNT (af.Id)
FROM ApplicationForm af
GROUP BY af.SubmitedDate
The problem is that field af.SubmitedDate also contains time part, sine I'm using SQL Server 2005, so the grouping is done by date-time, not only by date.
When I try to d...
Is it posible to control what objects get generated when using the SchemaExport tool. For example if I have NH mapping files for an EntityA, EntityB, and EntityC how can I exclude C from being created?
Roberto.-
...
I'm presenting data for users in a grid (ExtJS) with remote sorting and paging. Let's say I have a grid with some Orders. Order entity looks like Order{OrderNumber, Customer, Date, Address{Street, City, PostCode}}. Customer is mapped by NH as relation, Address is mapped as component. Data presented in the grid are flattened to columns na...
I've genereated a schema for my (SQL 2005) db using SchemaExport, and it's created a table
CREATE TABLE [dbo].[hibernate_unique_key](
[next_hi] [int] NULL
) ON [PRIMARY]
When I try to add an entity, I get the error "could not read a hi value - you need to populate the table". What am I meant to do?
edit: I've inserted a 1 into th...
I am having an odd error when using Fluent NHibernate. I have an entity object called Module that is my "aggregate root" if you will. I created and tested my mappings for the Module class and the various related classes and tried creating a Module with all of its fields filled out and saving it. This worked correctly.
My problem is w...
Hello,
I am having a problem loading objects using NHibernate. These entities have reference to files which no longer exist. When NHibernate assigns the 'Path' property of these entities these entities try to load the file which results in a an exception. The exception causes the loading transaction to roll-back completely.
I would lik...