我使用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