My database structure looks something like this:
Person
Id
Name
FieldA
FieldB
Phone
Id
Number
PersonPhone
PhoneId
PersonId
IsDefault
My NHibernate mappings for the Person and Phone objects are straight forward, its the PersonPhone I'm having difficult with. I want to have a collection of PersonPhone objects as a pr...
Hello,
I'm trying to map a Dictionary containing Lists.
I have the following set of tables:
CREATE TABLE Item(id)
CREATE TABLE Filter(id)
CREATE TABLE FilterType(id)
CREATE TABLE ItemFilter(
item REFERENCES Item(id),
filter REFERENCES Filter(id),
filterType REFERENCES FilterType(id)
)
and I want to do this mapping:
class Item...
I am trying to save a record which has a many-to-one property mapping. I attempt to assign a newly created parent object here (or use an existing, but that works fine) but I get an error when it tries to add the ID of the parent object to the child's table. Saying it cannot add NULL to the table, which is true, but I thought nHibernate w...
Iam trying to do some Eager loading with some entities that have a reference to one or zero elements.
The problem arises when it refers to zero element.
I have the following
class Car {
int id
string name
Driver driver
}
class Driver {
int id
string Name
}
The Driver gets loaded using
References(x => x.Driver).ColumnName("driv...
I have this class
public class Address:Entity {
public virtual string Address1 { get; set; }
public virtual string Address2 { get; set; }
public virtual string City { get; set; }
public virtual string State { get; set; }
public virtual string Zip { get; set; }
public virtual string Phone { get; set; }
public ...
Using HQL, how do you join on columns (or object properties) that are non PK/FK?
I'm reading the docs, and it seems it implicitly is going to join on the PK columns right?
https://www.hibernate.org/hib_docs/nhibernate/html/queryhql.html
...
I'm trying to get the AutoPersistence model to map several composite elements. However, it seems that either I end up mapping it as an entity, dropping down to manual mapping or it just doesn't plain work. Here's some code that demonstrates my problem:
using System;
using System.Collections.Generic;
using FluentNHibernate.AutoMap;
usi...
In other words how do you do something simple like this:
select 1
Or more specifically in the particular problem I'm dealing with, something like this:
SELECT (case when exists (<subquery>) then 1 else 0 end) AS result
So in short is there a way in NHibernate to do a select without having it generate the "FROM table" clause?
Thank...
Trying to delete an unmapped class/record via the NHibernate sql api.
But can't seem to get it working. Does anything look wrong with this?
session = NHibernateHelper.GetCurrentSession();
tx = session.BeginTransaction();
using (tx)
{
session.CreateSQLQuery("DELETE FROM tb_category WHERE parentID = :p...
Hi,
I have a following class:
MyClass
public virtual int Id { get; set; }
public virtual int Code { get; set; }
public virtual int Description { get; set; }
public virtual int Name { get; set; }
with the following mapping:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="TestAp...
I'm using NHibernate primarily against an MSSQL database, where I've used MSSQL schemas for the various tables.
In my NH mapping (HBM) files, I've specified the schema for each table in the mapping as follows:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
auto-import="true"
...
I am using NHibernate and ASP.Net using a session per request as suggested in the best practices article by Billy McCafferty (sorry, I cannot include the link). I have used this successfully with version optimistic locking, saving updated objects in the HTTP Session object and reattaching to the NHibernate session using the SaveOrUpdate...
We have a legacy database schema which I've tried (unsuccessfully) to map with NHibernate. To give a simplified example, say I want a Person class whose first name comes from the "Person" table, but their last name comes from the "Person2" table. The "Person" table also has the Id of the person's Car and I want my Person class to have a...
How can I get specific number of records from nhibernate like 10 or 15 at a time instead of all records.
I actually got the answer using criteria.setmaxresults().
But my question is how can I get first 10 records, then next 10 records and then.... next 10.......
...
hi
I have following mapping definitions:
<class name="Role" table="Role" optimistic-lock="version" >
<id name="Id" type="Int32" unsaved-value="0" >
<generator class="native" />
</id>
<property name="RoleName" type="String(40)" not-null="true" />
<bag name="UsersInRole" generic="true" lazy="true" cascade="all"...
Hi
Iam struggling with NHibernate and its lazyload.
I have a structure which I simplified but it show my issue.
Class Shift {
int ShiftID;
DateTime ShiftStart;
Employee Employee;
}
Class Employee {
int EmployeeID;
string Name;
}
Data:
ShiftData
ID SHIFTTIME EmployeeID (int)
1 ...
Hi I want to write a FindByExample(object o) method. So I tried this:
public IList<T> FindByExample(T o)
{
return Session.CreateCriteria(typeof(T)).Add(Example.Create(o)).List<T>();
}
(It's in a generic class)
It should work fine, but if T has a property of an enum type, it throws this exception:
"Type mismatch in NHibernate.Cri...
Do I need to create my own build of nHibernate and tools if i want to use the following frameworks in 1 project.
nHibernate
nHibernate Validators
Fluent NHibernate
xVal NHibernate Provider
nHibernate Linq
I am getting "Could not load file or assembly 'NHibernate," errors which I believe is because each framework is built against a ...
Hi,
I am using NHibernate interceptors to log information about Updates/Inserts/Deletes to my various entities.
Included in the information logged is the Entity Type and the Unique Id of the entity modified. The unique Id is marked as a <generator class="identity"> in the NHibernate mapping file.
The obvious problem is when logging an...
hi, i have two tables both are related with primary-foreign key ralation
and i have two corrosponding pojos
now can i write single property file(hbm) for both classes
if so can any one please give sample typical hbm file
...