I need to find out how to perform some action (flush cache) when an object of type X is updated.
So when I save object of type Y, nothing is done, when I save unchanged object of type X nothing should happed, but when this object is changed and UPDATE is made, I want to know it.
I tried various NHibernate events (IPostUpdateEventListe...
I'm experimenting with converting my NHibernate mapping files to FluentNHibernate. However, I'm already stuck on my first attempt. Here's a fragment of one XML mapping file:
<class name="Contact" table="tblXContacts">
<id name="_id" column="ContactID" unsaved-value="0" access="field">
<generator class="identit...
I have the following entity
public class Employee
{
public virtual int Id {get;set;}
public virtual ISet<Hour> XboxBreakHours{get;set}
public virtual ISet<Hour> CoffeeBreakHours {get;set}
}
public class Hour
{
public DateTime Time {get;set;}
}
(What I want to do here is store information that employee A plays Xbox everyda...
I have a class whose primary key is a single column, which is a reference to another object's single column primary key. The only way I can see to map this in NHibernate is to pretend it's a composite key (even though it's a single column key) and use the key-reference mapping. Is there a more appropriate way?
Snippet below:
class Comp...
Hello,
Using nHibernate, I would like to query on an integer datatype, but its always returning the exact match.
How could I write an expression that returns a list starting with the number entered?
right now I am using it as:
(clientNum is a long)
crit.Add(Expression.Like("ClientNumber", clientNum)); //this always gives me exact mat...
Hello,
Could anyone please describe how to use NHibernate Query Analyzer? I downloaded it and trying to build it but it fails, I am not quite sure how to use it.
I am using nHibernate with Sybase and WCF.
Any help is greatly appreciated.
Thanks
...
I have a child object in the database that looks like this:
CREATE TABLE Child
(
ChildId uniqueidentifier not null,
ParentId uniqueidentifier not null
)
An then I have a parent like so.
CREATE TABLE Parent
(
ParentId uniqueidentifier not null
)
Now, the problem is that in my Parent class, I have
public virtual Child Child { get;...
I'm using NHibernate with Lambda Extensions and I can't figure out how to phrase a specific kind of query.
My application lets users tag other users in pictures. So there are Picture objects, and each Picture has one or more Tag objects, and each Tag object has one User object.
I'm implementing a search feature. Given a search string, ...
Hello everyone,
I'm facing an extremely weird bug here and I'm not really sure If I'm following the right path to solving it or even how to solve it.
Here is the problem I'm facing: I start debugging a WPF application which uses log4net, NHibernate and LINQ to NHibernate, and when I try to get an Entity from the database my application...
In a test where I want to persist an object and then prove it was persisted by fetching it from the db (and not the session), I notice no difference between the following:
// save it
session.Clear()
// fetch it
or
// save it
session.Flush()
session.Evict(_instance)
// fetch it
The lazy programmer in me leans towards one line over t...
Have anyone stumbled upon a problem where NHibernate is extremely slow in Visual Studio while debugging, but behaves normally when run separately? Logging is disabled and the time lost seems to be when the actual queries are executed, NHProfiler shows that queries were executed very quickly (on SQL side I presume), but each session with ...
Hi,
I'm starting to use NHiberante as a dataaccess tier.
I'm used to work with the repository model as a business model.
This means, my domain model (not really a tier), my asp.net application tier, my repository tier which finally uses my dataaccess tier.
But with what I've learned by now (on NHibernate) I know that many logic is don...
Hi,
What is best pratices for inject and manage Session/Transaction for NHibernate using StructureMap for a Non Web Application like an Windows Service ?
In a web context, we use PerRequest Session management lifecycle using the Hybrid Lifecycle of StructureMap but for a Windows Service, i can't handle IDisposable UnitOfWork ...
Thank...
I downloaded Rhino Security today and started going through some of the tests. Several that run perfectly in isolation start getting errors after one that purposely raises an exception runs though. Here is that test:
[Test]
public void EntitiesGroup_IfDuplicateName_Error() {
_authorizationRepository.CreateEntitiesGroup("...
How should I manage my session? I've seen some examples where the session is created in the constructor of the domainservice and destroyed in the dispose method, but this seems like a bad idea.
Would appreciate help here because I can't find any information.
...
Hi everybody,
I'd like to know if is there something like a Trigger (of databases) in NHibernate that I can use per entity ?
I'd like to make a history of each record, and with triggers I can compare the old value and new value of each property and generate a register of history.
I've heard about Audit in NHibernate, but it's for al...
Hi,
we have an old, big asp.net application with nhibernate, which we are extending and upgrading some parts of it. NHibernate that was used was pretty old ( 1.0.2.0), so we decided to upgrade to ( 2.1.2) for the new features. HBM files are generated through custom template with MyGeneration. Everything went quite smoothly, except for o...
I am trying to recreate something like the following SQL using NHibernate criteria:
select Range, count(*) from (
select
case
when ent.ID between 'A' and 'N' then 'A-M'
else 'Other'
end as Range
from Subject
) tbl
group by tbl.Range
I am able to create the inner select as follows:
session.CreateCri...
I have a weird situation. I have three entities, Company, Employee, Plan and Participation (in retirement plan).
Company PK: Company ID
Plan PK: Company ID, Plan ID
Employee PK: Company ID, SSN, Employee ID
Participation PK: Company ID, SSN, Plan ID
The problem is in linking the employee to the participation. From a DB perspective, p...
I have a component which contains a collection. I can't seem to get NHibernate to persist items in the collection if I have the collection marked as Inverse. They will persist if I don't have Inverse on the collection, but I get an insert and then an update statement.
My mapping is :
m => m.Component(x => x.Configuration, c =>
{
c...