nhibernate

NHibernate doesn't save one property only

随声附和 提交于 2019-12-24 01:15:27
问题 I'm trying to update a single column in the table. No UPDATE issued whatsoever (checked using SQL Profiler). No errors. Class mapping has dynamic-update="true" . No versioning enabled on the class. Flush mode Commit. Property mapped without any insert/update modifiers ( <property name="Deleted" /> ). Property is auto-implemented ( public virtual bool Deleted { get;set;} ). NH 3.3.0, .NET 4, x64. using (var transaction = this._session.BeginTransaction()) { try { var order = this.session.Load

System.Data.SQLite BadImageFormatException with NHibernate, works finewhen standalone

被刻印的时光 ゝ 提交于 2019-12-24 01:01:30
问题 I tried to use NHibernate with SQLite, version=1.0.74.0 for .NET 4 and 32 bit. I use a 64bit WIN7, but build the application in x86 mode (default in VS2010 express). When I use the same SQLite as a standalone application it works fine, but when I try to use it with NHibernate it throws BadImageFormatExcepion I debugged a bit NHibernate and the Exception is thrown at the folllowing statement System.Type.GetType("System.Data.SQLite.SQLiteConnection, System.Data.SQLite"); Any chances somebody

Hibernate returning the values in session, but not from the database

旧城冷巷雨未停 提交于 2019-12-24 00:58:03
问题 I get an entity 'A' using getHibernateTemplate().get(A.class, 100) from the database. Lets say this entity 'A' has a property 'value' 200 in the database. Now, in my Java code, I change a property for this entity. lets say, I change the 'value' property to '500' and then add it to some list. Now, If I again do getHibernateTemplate().get(A.class, 100) for the same Entity, I am getting the updated entity(that has a value of 500). How do I force hibernate to get me the entity from the database,

nhibernate queries SubQueryExpression

独自空忆成欢 提交于 2019-12-24 00:48:29
问题 Can someone explain me what are NHibernate SubQueryExpression based queries. Any links with concrete examples are very welcome. Thanks Update: Let's say that I have one entity named Beach. That beach can have many images. I want to select Beach entity and it;s first image from Images collection. I want to carry arround only that selected image object, or if I select only second object to carry only that object. I do not want to access like Images.First() cause that will initialize all

Nhibernate QueryOver Orderby

≯℡__Kan透↙ 提交于 2019-12-24 00:45:59
问题 I'm trying to decouple the orderby on a queryover call and this doesn't compile protected static void AddOrder<T>(IQueryOver<T, T> criteria, Expression<Func<object>> expression ) { criteria.OrderBy(expression).Asc; } I'm guessing there is a way to do this, somehow bringing in the asc into the linq expression? Thanks for the help! 回答1: That's not how IQueryOver works... to make it compile, you'd have to do the following: protected static IQueryOver<T, T> AddOrder<T>(IQueryOver<T, T> criteria,

NHibernate one expression can be specified in the select list when the subquery is not introduced with EXISTS

亡梦爱人 提交于 2019-12-24 00:45:30
问题 I am having class which contain property which is list of some other class. I want to map this class to another class in queryable extension. AutoMappper.CreateMap<Department1, Department2>() AutoMapper.CreateMap<Employee1, Employee2>() var employee1 =_session.Query<Employee1>(); employee1.Project().To<Employee2>(); It give error 'Could not excecute query Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.' select employee1_.Id as col_0_0_,

group by month and year parts using queryover

自作多情 提交于 2019-12-24 00:41:01
问题 I have a model, that contains a DateTime field and a Price field. I want to get a list that gives me an aggregation of month/year - price so for the data: 15/01/2012 200 16/01/2012 200 15/02/2012 300 16/02/2012 300 15/03/2012 400 16/03/2012 400 I will get: 01/2012 400 02/2012 600 03/2012 800 So far I didn't find a way to achive this using QueryOver. I keep getting "could not resolve property" when i try to look at the Month/Year parts of the date. Those questions: Group posts by year, then by

NHibernate HQL: How to use the new object constructor with 'distinct'?

六眼飞鱼酱① 提交于 2019-12-24 00:25:58
问题 I need to use the HQL object constructor feature , e.g: select new SomeClass(i.Id, i.Name) from Item i... But I also need to use the distinct keyword , as there are joins further down in the query, e.g.: select distinct i.Id from Item i I have tried this: but it just causes an Antlr exception, so I assume it's invalid syntax: select new SomeClass(distinct i.Id, i.Name) from Item i Is this possible? 回答1: Ah, it looks like this works: select distinct new SomeClass(i.Id, i.Name) from Item i...

Why is Fluent NHibernate ignoring my convention?

断了今生、忘了曾经 提交于 2019-12-24 00:19:59
问题 I have a convention UserTypeConvention<MyUserType> where MyUserType : IUserType where MyUserType handles an enum type MyEnum . I have configured Fluent NHibernate thusly sessionFactory = Fluently .Configure() .Database(MsSqlConfiguration.MsSql2005.ConnectionString( c => c.Is(connectionString)) ) .Mappings( m => m .FluentMappings .AddFromAssemblyOf<A>() .Conventions .AddFromAssemblyOf<A>() ) .BuildSessionFactory(); where A is a type in the same assembly as UserTypeConvention<MyUserType> and

Fluent Nhibernate: Trying to create entity with composite key that is also the keys for two references

时光怂恿深爱的人放手 提交于 2019-12-24 00:16:12
问题 The references are unidirectional. The table (StoreProduct) for this entity is actually a join table that has these fields: Store_id Product_id ExtraBit So I went with an entity having a compoundID (store_id and product_id) and the ExtraBit is just a string: public class StoreProduct { protected StoreProduct():this(null,null,null){ } public StoreProduct(Store c_Store, Product c_Product, String c_ExtraBit) { Store = c_Store; Product = c_Product; ExtraBit = c_ExtraBit; } public virtual int