Please excuse my ignorance on the topic, as I am relatively new to Hibernate / NHibernate, but I have encountered a mapping I can't figure out:
This is what my database table looks like:
<bincontents>
<id>5873715</id>
<title>Video Title</title>
<sortorder>0</sortorder>
<itemid>23079</itemid>
<itemtype>VIDEO</itemtype>
<...
I'm having trouble with something that (I think) should be simple, but can't find any clear info.
In the scenario where I have three tables, describing a domain where a person can have more than one job:
Person - has PersonId, Name
Job - has JobId, JobName
PersonJob - has PersonId, JobId, YearsOfEmployment
Note: In my object mode...
Here is the domain that I wish to have:
public class Person
{
public int Id { get; set; }
public IList<AcquiredCertificate> AcquiredCertificates { get; set; }
}
public class AcquiredCertificate
{
public Person Acquirer { get; set; }
public Certificate Certificate { get; set; }
public DateTime DateAcquired;
}
public class Certific...
I have a problem. Imagine this data model:
[Person] table has: PersonId, Name1
[Tag] table has: TagId, TagDescription
[PersonTag] has: PersonId, TagId, IsActive
Since [PersonTag] isn't just a simple many-to-many join table, i have all three entities created in nHibernate (exactly like they are in the data model). PersonTag, therefor...
I'm trying to figure out how to map a component as a primary key in nhibernate and if possible in fluent nhibernate as well.
The component in question is a unique set of 3d coordinates, here's the object:
public class SpaceLocation
{
public virtual SpaceCoordinate Coordinates { get; set; }
public virtual SpaceObject AtLocation...
Is it possible to map an enum as a string using Fluent Nhibernate?
...
My Microsoft SQL Server 2005 database contains a table that has an XML field that has some important metadata, and under normal SQL I could run the following query and get a list of items which don't have UPC codes set... Unfortunately I'm having a hard time re-creating this query using NHibernate's Criteria API:
SELECT [Id],[meta].valu...
Datastructure is:
Table[Questionnaire] the top node
Table[QuestionGroup] just a grouping
for heading etc
Table[QuestionnaireQuestion] mapping
[Question]<->[QuestionGroup]s many to many relationship and the [Questionnaire]<->[Question]s many to many relationship
Table[Question]
One question can exist in many questionnaires/questiongro...
Hello,
In my system, I have two entities - ShoppingCart and ShoppingCartItem. Fairly generic use-case. However, when I save my ShoppingCart, none of the items are being saved to the DB.
Within my object, I create a new ShoppingCart object.
ShoppingCart cart = CreateOrGetCart();
I then add an existing Product which I got from the data...
I'm mapping a legacy database with nhibernate and having some problems with mapping a realation.
The two classes look like this
public class Questionnaire
{
public int Id {get; set;}
public string FormCode {get; set;}
public IList<Question> Questions {get; set;}
}
public class Question
{
public int Id{get; set;}
pu...
I'm looking for an editor that has the help from
http://www.hibernate.org/hib_docs/nhibernate/html/mapping.html
built in, and allows simple editing of the XML files in a GUI fashion. I realise there's CodeSmith and MyGeneration, but from what I remember these only go one way, and don't allow editing existing HBM files.
...
I'm newish to NHibernate, and am attempting to wire up to a DB2 table through the ISeries provider. The table has a BIGINT primary key that is auto generated as an identity. I've tried several values for the generator property of the id in my mapping file, and haven't had any success. The table def looks like so (field names changed):...
Assume that I have Person and Address Classes and they have different tables in DB.
One Person can have one Address Class in it. This is the important part for me. One Person can have only one Address as it s child element and i want to keep them in different tables in DB.
Normally i know that i need to hold them in the same table, but...
How can I create generic component mapping in NHibernate, I have a class Pair{virtual T First{get;set}, virtual T Second{get;set;}}, I am trying to map it with something like this which is not working
...
Lets say i have this database design:
Items
Id
Name
Desc
ItemTags
ItemId
TagId
Tags
Id
Tag
And i want to map it to the following class
class Item
int Id
string Name
string Desc
IList<string> Tags
Please note that I don't want to declare class Tag, i just want the Item class to have list of strings that repre...
Hi
I'm getting a strange NHibernate exception when I try and create a SessionFactory. I've narrowed down the exception 'Unable to cast object of type 'NHibernate.Mapping.Bag' to type 'NHibernate.Mapping.IKeyValue' to the following mapping on the Company object:
<bag name="Images" cascade="none">
<key column="CompanyId" property-ref...
Hi,
I am trying to build a messaging system and for this i have the table definition below
Message
Id
From
To
Body
ParentId // Subcollection, i want to get Asnwers (Message.ParentId== Message.Id)
IsRead
and i have this in the Message.cs
IList<Message> Answers;
I have tried this but it gives me all the messages and all the answers...
Lets say we have an Employee entity composed of a few other entities, such as a one-to-many addresses and contacts, and a few fields (name, age, etc). We mapped this entity out and can use it just fine, saving each piece out into "Employee", "EmployeeAddresses", and "EmployeeContacts" tables.
However, we use pretty much all of this empl...
I'm having some trouble getting NH to persist my object graph.
I have (something like) this:
/*Tables*/
TABLE Parent
ParentID PK
LastEventID NULL
TABLE Event
EventID PK
ParentID FK NOT NULL
//Model Classes
public class Parent
{
public List<Event> Events; //Inverse
//Denormalized bit
public Event LastEvent; ...
I'm getting this exception (Full exception at the bottom):
NHibernate.PropertyValueException was unhandled by user code
Message="not-null property references a null or transient
valueClearwave.Models.Encounters.Insurance.Patient"
Source="NHibernate"
EntityName="Clearwave.Models.Encounters.Insurance"
PropertyName="Patient"
I've don...