I am getting the following error in an Asp.Net Castle ActiveRecord app when trying to update an object:
"a different object with the same identifier value was already associated with the session"
I've looked up and down my code to see where else the object might have been created but I'm not seeing it. This is baffling as I have the ex...
I've got a simple domain object, Movie, with the following constructor:
public Movie(string title, int year = 0, Genre genre = Genre.None, int length = 0, IEnumerable<string> actors = null) { ... }
There is no ID parameter, as there couldn't be a way to know up front what the ID would be. Movie does have an int Id property.
This obje...
I have a session criteria statement (Fluent NHibernate) that does not seem to filter the child collection even though I have Expressions/Restrictions defined.
ICriteria criteria = session.CreateCriteria(typeof(MyClass));
criteria.CreateAlias("MyCollection", "MC");
criteria.Add(Restriction.Eq("MC.Property", value));
IList<MyClass> list =...
Let's start with this mapping:
<component name="Location">
...
<property name="Settings" type="JsonUserType,...">
<column name="LocationSettingsType" />
<column name="LocationSettingsData" />
</property>
</component>
This maps to
TABLE Primary (
...
LocationSettingsType,
LocationSettingsData
...
)
and
...
I'm trying to map a List with an index column. This works fine, but i would also like to be able to query the index column from HQL. When i do that HQL throws an exception:
NHibernate.QueryException: could not resolve property: Position of: component[Location,Time]
To be able to query the WayPoint.Position column from HQL, i have creat...
I have a class that has a many to one property defined as follows:
[NHMA.ManyToOne(Name = "TypeOfEvent", ClassType = typeof(EventType), Column="EventTypeId")]
public virtual EventType TypeOfEvent {get; set;}
Everytime I try to load the class using a simple query (just loading all of the events in the database) I get the following exce...
Good afternoon.
Before I begin my explanation, I have had a look at other similar questions but the subtle differences (mainly in purpose of design) mean that the solutions provided in these answers to not apply to me.
I am attempting to create a 'Base data access library' for use with future projects so that I do not have to spend my ...
Hi,
I have problem with saving object to database with NHibernate. Program throws no error but record is still not in database. I am also outputting sql queries and the query is not executed.
I use composite key in table "order_product". Table is child of "order".
Database table: order_product
order_id (PK)
product_id (PK)
count
pric...
Hi there,
I hope someone can give me some suggestion on how to face this issue.
I have a S#arp Architecture application with a primary centralized db and that works fine.
I need to extract data from the central bd and save it to a smaller sqlite db and then, eventually import it back.
The sqlite connection has to be temporary. Open the ...
Dear All!
In my ASP.NET web-application I use NHibernate to persist my "User"-Instances, where each of them has a "Entries" - collection. It is a typical one-to-many mapping and it works just fine. The mapping-code for the entries looks like this:
<bag name="Entries" cascade="all-delete-orphan">
<key column="UserID" />
<one-to-ma...
How to represent next nhibernate xml in fluent-nhibernate?
<set name="Items" lazy="true" table="CATEGORY_ITEMS">
<key column="CATEGORY_ID"/>
<composite-element class="CategorizedItem">
<parent name="Category"/>
<many-to-one name="Item"
class="Item"
column="ITEM_ID"
...
Suppose I was writing an application where users had to book appointments (in my case, a user is paired with an employee and that employee will do work for that user at a particular time of day). How would I ensure that 2 users did not end up booking the same appointment using NHibernate or Entity Framework? Would I open a transaction an...
Hi,
I'm using NHibernate 2.2 for my database work and I've faced an issue recently. I have a class called PrescDrugItem which is shown below
public class PrescDrugItem
{
public virtual int ItemNumber { get; set; }
[DataMember]
public virtual int AmountIssued { get; set; }
[DataMember]
public virtual string TimePer...
This is a set collection:
<set access="field.camelcase-underscore" cascade="save-update" inverse="true" lazy="true" name="employees" table="TeamEmployee" mutable="true">
How do I set the name attribute?
...
I am using NHibernate on a project. The database is required to have creation date and creator user fields on relation tables but I do not want to map the relations to domains. My db design is like:
school (id, name, credate, creuser)
student (id, name, credate, creuser)
school_student(id, school_id, student_id, credate, creuser)
For ...
I'm following on from a previous question. The answer I accepted involves using a generic IRepository to handle basic CRUD, wrapped with a domain specific IMovieRepository which delegates to the generic setup. A further detail involves having a WrapQueryInSession method on the generic IRepository:
IEnumerable<T> WrapQueryInSession(Func<...
Hi everyone,
I encountered a very embarassing problem yesterday.
My particular experience is with NHibernate and Mono, but I see similar cases involving other projects everywhere.
While everyone seems to claim that NHibernate is working on Mono, I must admit that I actually tried yesterday, and the 3.0 trunk doesn't work. To me, this i...
Hi,
I am using NHibernate 3 Alpha 2, and I am trying to do the number of posts per month
This is the code I came up with
List<PostMonthFrequency> monthFrequencies = _postRepository
.FindAll()
//.ToList() //<- if included works. however not desired
.OrderByDescending(x => x.PublishedOn)
.GroupBy(x => new {x.PublishedOn....
Hi,
I have simple HQL query:
var list = OpenSession()
.CreateQuery("SELECT MAX(p.price) as max_price,
COUNT(p.id) as count_all
FROM Order o left join o.Products p")
.List();
I would like to output "max_price" and "count_all" columns/projectio...
Can NHibernate linq/lambda expressions be compiled so they aren't reevaluate on every use?
...