nhibernate-3

Join multiple tables with NHibernate and QueryOver

自作多情 提交于 2019-12-07 09:22:40
问题 I have this tables: Person -> PersonFavorites, PersonCompany PersonCompany -> Company I have now to do the following select with NHibernate and QueryOver: select * from Person inner join PersonFavorites on Person.Id = PersonFavorites.PersonId inner join PersonCompany on Person.Id = PersonCompany.PersonId inner join Company on Company.Id = PersonCompany.CompanyId where ... Can someone give me a sample, how I can do that? - My Problem is, that I have to join multiple Tables Person ->

Soft Delete Nhibernate

折月煮酒 提交于 2019-12-06 06:24:18
问题 I want to make a soft delete on my db table...i have apply following statement (as described here http://nhibernate.info/blog/2008/09/06/soft-deletes.html and in a lot of question on SO). Fattura is my table where i want apply logical delete (there is no trigger on it) Fattura.hbm.xml <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Paggentola.Gestionale.DL.Model" namespace="Paggentola.Gestionale.DL.Model"> <class name="Fattura" table=

Join multiple tables with NHibernate and QueryOver

梦想的初衷 提交于 2019-12-05 13:27:36
I have this tables: Person -> PersonFavorites, PersonCompany PersonCompany -> Company I have now to do the following select with NHibernate and QueryOver: select * from Person inner join PersonFavorites on Person.Id = PersonFavorites.PersonId inner join PersonCompany on Person.Id = PersonCompany.PersonId inner join Company on Company.Id = PersonCompany.CompanyId where ... Can someone give me a sample, how I can do that? - My Problem is, that I have to join multiple Tables Person -> PersonCompany -> Company. The Join Person -> PersonCompany and Person -> PersonFavorites are no problem - but the

What is the difference between ISession.SaveOrUpdateCopy() and ISession.Merge()?

孤者浪人 提交于 2019-12-05 07:10:24
In NHibernate 3.1, ISession.SaveOrUpdateCopy() has been marked as deprecated. The documentation suggests using Merge() instead. The documentation for each is as follows: SaveOrUpdateCopy(object obj) Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the

Soft Delete Nhibernate

我是研究僧i 提交于 2019-12-04 12:02:24
I want to make a soft delete on my db table...i have apply following statement (as described here http://nhibernate.info/blog/2008/09/06/soft-deletes.html and in a lot of question on SO). Fattura is my table where i want apply logical delete (there is no trigger on it) Fattura.hbm.xml <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Paggentola.Gestionale.DL.Model" namespace="Paggentola.Gestionale.DL.Model"> <class name="Fattura" table="Fattura" where="Cancellato=0"> <id name="Id_Fattura" column="Id_Fattura"> <generator class="native" /> <

NHibernate 3 specify sql data type with loquacious syntax

南楼画角 提交于 2019-12-04 04:43:02
问题 I'm trying to map an Entity with a string property to a varchar column in NHibernate 3 using the new Loquacious API but I can't figure out how to specify the Type to use. I am able to correctly map the entity with NHibernate 2 and FluentNHibernate. NHibernate 2 w/Fluent Mapping public class EntityMapping : ClassMap<Entity> { public EntityMapping() { Table("EntityTable"); Id(x => x.EntityId).Column("EntityId").GeneratedBy.Identity(); Map(x=>x.Code).Not.Nullable().Column("EntityCode")

What can be used as a NHibernate QueryOver alias?

做~自己de王妃 提交于 2019-12-02 12:19:50
问题 I know so far that a local variable or a local property can be used as an alias like so ClassA _aliasA; _session.QueryOver(x => x.ClassA, () => _aliasA); or ClassA AliasA { get; set; } _session.QueryOver(x => x.ClassA, () => AliasA); I want to know what other options are possible. Like, are properties of an external class a valid option? class ClassGenericAliases { ClassA Class { get; set; } } _session.QueryOver(x => x.ClassA, () => ClassGenericAliases.ClassA); Can statics be used as aliases?

NHibernate Current Session Context Problem

心不动则不痛 提交于 2019-12-01 01:30:06
问题 I've recently moved from using an ISession directly to a wrapped ISession, Unit-of-Work type pattern. I used to test this using SQL Lite (in-memory). I've got a simple helper class that configures my SessionFactory, created an ISession and then built the schema using SchemaExport and then returned my ISession and the schema lived until I closed the session. I've changed this slightly so that I now configure a SessionFactory, create an ISession, build the schema, and pass the factory to my

Breaking changes with NHibernate 4 upgrade

百般思念 提交于 2019-11-30 23:02:15
I can see what's new and fixed in NHibernate 4.0 I would like to know if anyone has had issue with hbm mappings upgrading from NHibernate 3 to 4? I fear that more focus is going on fluent mapping these days. I can test for the more obvious breaking changes but wanted to know if there were any subtle issues that anyone has come across in a production environment that may not be so obvious at first. It looks like a major upgrade and you'd expect there to be the risk of regressions. FYI, I found a new error that is thrown. We use Mapping By Code, and we used to have an entity that had multiple

NHibernate 3.0: TransactionScope and Auto-Flushing

╄→гoц情女王★ 提交于 2019-11-30 15:34:24
问题 In NHibernate 3.0, FlushMode.Auto does not work when running under an ambient transaction only (that is, without starting an NHibernate transaction). Should it? using (TransactionScope scope = new TransactionScope()) { ISession session = sessionFactory.OpenSession(); MappedEntity entity = new MappedEntity() { Name = "Entity", Value = 20 }; session.Save(entity); entity.Value = 30; session.SaveOrUpdate(entity); // This returns one entity, when it should return none var list = session.