I have a use-case in my app where I need the first two levels of my object tree.
I have an object called Player which has a list called CheckIns
that holds a many-to-one connection to Player as an object reference
when I execute the Query I get back a seemingly endless chain of
Player->CheckIns->Player->CheckIns and so on..
What I nee...
I need to persist this class on database using Fluent NHibernate:
public class RaccoonCity
{
public virtual int Id { get; private set; }
public virtual DateTime InfectionStart { get; private set; }
private IList<Zombie> _zombies = new List<Zombie>();
public virtual IEnumerable<Zombie> Zombies
{
get { retu...
I have an application where I want to take a snapshot of all entities, creating cloned tables that represent a particular point in time. I then want to be able to compare the differences between these snapshots to see how the data evolves over time.
How would you accomplish this in NHibernate? It seems like NH isn't design for this type...
I have a set of elements that belong to a tree. I only care about the ancestors, I don't care about the children. For example I want the tree to look like this:
Barbeque Supplies*
Household cleaning Supplies
Air fresheners
1. Car Airfreshner*
Paper Towels*
Utensils
Forks*
The only input I'm given are the starred elements. So I...
i have two tables:
Components
ComponentDependencies
ComponentDependencies has two columns: ComponentId and ComponentDependencyID. (both foreign keys into Id field of Component table.
i am using fluent nhiberate and i have my component object having:
public virtual IList<ComponentDependency> Dependencies { get; set; }
and in my C...
Hi,
I am using Fluent NHib which generates the mappings bellow. I read this: http://www.progware.org/Blog/post/NHibernate-inverse3dtrue-and-cascade3dsave-update-demo.aspx but I still cannot figure it out. The only difference is that I am using GuidComb for PK.
Parent:
<bag access="nosetter.camelcase-underscore" cascade="save-update" i...
My members will have the ability to customise their profile page with X amount of widgets, each widget displays different data such as a list of music, list of people they are following etc.
Several widgets include:
- List of media they have uploaded
- List of people they are following
- List of people following them
- Html/Text wid...
The following is a simple test of a repository against FluentNHibernate-1.1.0.685 (NHibernate-2.1.2.4000). The Session and NH config are provided by the test fixture.
[Test] public void ShouldEdit() {
var employee = CreateEmployee();
session.Clear();
var changedEmployee = _testRepository(employee.id);
changedEmployee....
With the following mapping, BillingAddress.Country is mapped correctly but ShippingAddress.Country is always null. Maybe it's because of equal properties name? but they are different objects... Any idea how to fix it?
Thanks ahead.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="K...
Hi,
I have the following SQL Query returning the results I need:
SELECT
Person.FirstName,Person.LastName,OrganisationUnit.Name AS UnitName, RS_SkillsArea.Name AS SkillsArea, Activity.Name AS ActivityName, Activity.CLASS, Activity.StartsOn, Activity.EndsOn,
SUM(ActivityCost.CostAmount) /
NULLIF(
(
SELECT COUNT(Registration.A...
I'm using NHibernate. I have a class which has a nested type. Is there any way, using NHibernate, to query against the nested type, asides from using a native SQL query?
Nested classes are not allowed in HQL currently.
EDIT: The outer class has an IList of nested class instances.
...
Hi all
I've just got to grips with the basics of NHibernate, and while refactoring my data access and domain layers I thought I might as well get cute and start using dependency injection for the data access layer. Unit testing here we come!
I thought since NHibernate uses loads of Castle dlls I might as well use Castle Windsor for th...
Hi!
After I retrieve an entity, I change a property of it.
Then I retrieve the same entity.
How do I say Nhibernate, that it shall update the entity before it loads the entity?
Here the code:
EmployeeRepository employeeRepository = new EmployeeRepository();
Employee employee = employeeRepository.GetById(4);
employee.LastName = "TEST...
As an example, let's say you have a class like such
**Person**
int PersonID
string PersonName
BusinessLocation Locations
**BusinessLocation**
string city
string state
List<int> ZipCodes
(saying that the locations may exist in multiple zipcodes)
(also ignoring that zipcodes should be strings instead of ints, this is just an example)
...
Sql Server 2008 R2 Express. NHibernate 2.1.2.4.
I get SQL like:
SELECT customer0_.Id as Id1_0_
FROM customers customer0_
WHERE customer0_.Id=@p0;
@p0 = 11111111-1111-1111-1111-111111111111
...which returns 0 records even though there is Customer in there with that Id.
The SQL Server column datatype is UNIQUEIDENTIFIER.
<session-f...
Hi all
Just a quickie ... I have the following ID generator strategy for one of my mapped classes:
<id name="UID" type="System.Guid">
<column name ="UID" sql-type ="uniqueidentifier" />
<generator class="guid.comb" />
</id>
The entity in question is involved in synchronisation / merging behaviours from which it is necessary t...
Hi all
As part of my endless NHibernate-inspired DAL refactoring purgatory, I have started to use the Repository pattern to keep NHibernate at arms length from my UI layer. Here's an example of a Load method from a repository.
public StoredWill Load(int id)
{
StoredWill storedWill;
using (ISession session = NHibernateSessionFactory...
Question:
What are the criteria/projections that can generate a following query?
SELECT SUBSTRING(Name, 0, 1) FROM Person GROUP BY SUBSTRING(Name, 0, 1)
(Obviously this one is easier with DISTINCT, but I'll need counts later, when I fix this one).
My approaches:
My main problem here is with constants, because if I use
Projecti...
I have the following hql query which I'd like to switch over to the criteria API
select a.Id as Id, a.Name as Name, a.ActiveStatus as ActiveStatus,
dbo.GetActivityStartDate(a.Id) as StartDate,
dbo.GetActivityEndDate(a.Id) as EndDate,
coalesce(ac.Id,0) As CategoryId,
coalesce(ac.Name,'') As CategoryName
from Activity as a
left oute...
Consider the following scenario:
Class A has a one-to-many relationship to Class B.
Class B has a many-to-one relationship to Class C.
class A {
IList<B> BList {get;set;}
}
class B {
C CMember{get;set;}
}
class C {
//null
}
If I load class B from the database using something like
IList<B> result = query.List<B>();
every...