I have a domain class that when persisted to Oracle must update a column to sysdate. NHibernate must only generate 1 SQL. e.g.
update person set age = 12, stamp = sysdate where id = 1;
Can this be done?
EDITED:
Could be something like:
Person person = (Person)session.Get(typeof(Person), 1);
session.SetFunction(person, "stamp", Funct...
This is probably a simple question to answer but I just can't figure it out.
I have a "Company" class with a many-to-one to "Address" which has a many to one to a composite id in "City". When I load a "Company" it loads the "Address", but if I call any property of "Address" I get the error:
{"could not load an entity: [IDI.Domain.Ent...
Sybase ODBC driver have an issue with the decimal data type.
For example, when an application is trying to save in the database a decimal value occurs this error:
ERROR [22018] [DataDirect][ODBC Sybase Wire Protocol driver][SQL Server]Implicit conversion from datatype 'VARCHAR' to 'DECIMAL' is not allowed. Use the CONVERT function to...
I have a situation where I have a Common.Domain.Person and Specific.Domain.Person.
First one should be provided as a part of a common package.
Second one appears when common package has to be customized to fit the needs of specific project.
In the object model, it can be easily implemented with inheritance.
In the NH mapping, however...
Hi all. I am trying to query a table that looks like this
CatalogProduct
CatalogId - FK to Catalog
ProductId - FK to Product
The product table has a ParentProductId which is an FK to itself.
using the NHibernate criteria API, i need to get a list of CatalogProducts where the CatalogId is and the ProductId is the Product.ParentPro...
Hi.
I do Update with SaveOrUpdateCopy(). Now, I have attached an event for this:
this.EventListeners.SaveOrUpdateCopyEventListeners = new IMergeEventListener[] { new AuditableSaveOrUpdateCopyEventListener() };
In the AuditableSaveOrUpdateCopyEventListener, I have inherited from DefaultSaveOrUpdateCopyEventListener and overrid...
i,
I have a parent child relationship, let's say class and children. Each child belongs to a class and has a grade. I need to select the children (or the ids of the children) with the lowest grade per class.
session.CreateCriteria(typeof(Classs))
.CreateAlias("Children", "children")
.SetProjection(Projections.ProjectionList()
.A...
I have set up my mapping file and classes as suggested by many articles
class A { ... IList BBag {get;set;} ... }
class B { ... A aObject {get;set;} ... }
<class name="A">...<bag name="BBag" table="B" inverse="true" lazy="false"><key column="A_ID" /><one-to-many class="B" /></bag>...
<class name="B">...<many-to-one name="aObject" cla...
I have this very simple class
public class ProductAttributeValuePortal
{
public virtual int ID { get; set; }
public virtual Domain.Entity.Portals.ProductPortal Product { get; set; }
public virtual Attribute Attribute { get; set; }
public virtual string Value { get; set; }
}
with this very simple map
public ProductA...
I have the following code:
public IEnumerable<MyClass> GetFirstData()
{
return session.CreateCriteria<MyClass>()
// ICriterions here
.Future<MyClass>();
}
public IEnumerable<MyClass> GetSecondData()
{
return session.CreateCriteria<MyClass>()
// different ICriterions here
.Future<MyClass>();
}
t...
Does any body know how if there is a way to tell if an entity is already in the NHibernate second level cache?
Ideally what I'd like to be able to do is pass the identifer of an entity to NH and find out if it's already in the second level cache.
...
I'm using NHibernate with SQL Server 2005 in a WPF client application.
If I manually stop the SQL Server service and then restart it the session doesn't automatically reconnect.
So far I'm doing this witch seems to work :
try
{
using (ITransaction transaction = this.Session.BeginTransaction())
{
// some select here
...
I've raised this question before but am still struggling to find an example that I can get my head around (please don't just tell me to look at the S#arp Architecture project without at least some directions).
So far I have achieved near persistance ignorance in my web project. My repository classes (in my data project) take an ISession...
Hi
I want to call the Stored procedure from My nHibernate Application thats stored Procedure return the List and i will return back to the UI How to call the SP can any one help me on this?
...
Hi
I have the version 3.0.0.1001 nhibernate.
My objects are basically modeiling a lineup at an event. So I have a StageSet object which represents one slot in the schedule for a stage.
Each StageSet object has a Stage and an Act property.
It also has many Users - people who have favorited the set.
I'm trying to ascertain the most po...
Hi,
I want to track a list of root objects which are not contained by any element. I want the following pseudo code to work:
using (session1 = [...]) {
IList<FavoriteItem>list = session1.Linq<FavoriteItem>().ToList();
}
list.Add(item1);
list.Add(item2);
list.Remove(item3);
list.Remove(item4);
var item5 = list.First(i => i.Name = "Fo...
Hi all, I'm developing a web application using asp.net Mvc 2 and NHibernate, and I'm paging data (products in a category) in my page, but this data are random, so, I'm using a HQL statement link this:
string hql = "from Product p where p.Category.Id=:IdCategory order by rand()";
It's working fine, but when I page, sometimes the same p...
I want to call the sp from the application with out specifying anything in the mapping file my sp return is a list.
public IList<INewItem> GetItemsByfilter(IList<object> Filters)
{
// call sp with out using the mapping file sp returns a dataset
}
...
I've implemented an event that is fired every time a value changes in a class.
I also have a class that has a collection of those items and I'd like to subscribe to those items events. I'm trying to do so in the setter of a property like this:
public virtual ISet<ItemType> items
{
get
{
return this._items;
}
set
{
this._ite...
Hello,
I have simple situation (like on the image link text) and simple SQL query
SELECT M.Name,
A.Name,
B.Name
FROM Master M LEFT JOIN DetailA A
ON M.DescA = A.Id LEFT JOIN DetailB B
ON M.DescB = B.Id
How to achive the same effect in nHibernate using CriteriaAPI ?
I have something like this:
public c...