我使用NHibernate 3.2NHibernate的嘗試,當我做一個選擇
我在一個交易,節省了一些東西,和之前commiting,我試圖詢問一些元素,它拋出我一個插入oracle插入錯誤。
我的查詢(HQL):
MySession = SessionFactory.OpenSession().BeginTransaction();
/*Do some saves but don't commit*/
var hql = @"select distinct c
from Car c inner join c.Manufacturer manuf where manuf.Id = 449"
MySession.CreateQuery(hql).List<Car>(); /*throws error*/
當我執行此查詢時,它拋出我下面的錯誤
ORA-01400: cannot insert NULL ...
我的映射與創建:
lazy="true" dynamic-update="true" dynamic-insert="true"
會議工廠代碼:
private static ISessionFactory _sessionFactory;
private static ISessionFactory SessionFactory
{
get
{
if (_sessionFactory == null)
{
var configuration = new Configuration();
configuration.Configure();
configuration.AddAssembly(typeof(EstoqueEquipamento).Assembly);
_sessionFactory = configuration.BuildSessionFactory();
}
return _sessionFactory;
}
}
public static ISession OpenSession()
{
return SessionFactory.OpenSession();
}
謝謝。
你什麼時候刷新/提交會話? – Dan 2012-02-01 18:05:52
會在我查詢後的那一行,但它從來沒有到達那裏,因爲錯誤被拋出。 – 2012-02-01 18:06:36