如何正确使用Fluent NHibernate获取Oracle中的下一个Sequence?
我正在将 NHibernate / Fluent NHibernate 与 Oracle 结合使用,但遇到了问题。我定义了以下映射文件:
public OrderMap()
{
Table("ORDERS");
Id(x => x.OrderId, "ORDER_ID").GeneratedBy.Sequence("select ORDERS_SQ.nextval from orders");
Map(x => x.CreatedBy, "CREATED_BY");
Map(x => x.OrderStatusCd, "ORDER_STATUS_CD");
Map(x => x.StoreGroupId, "STORE_GROUP_ID");
Map(x => x.IsActive, "IS_ACTIVE");
Map(x => x.OrderDate, "ORDER_DATE");
}
当我运行我的项目时,出现以下错误:
创建 SessionFactory 时使用了无效或不完整的配置。
如果我删除 .GenerateBy.Sequence("select ORDERS_SQ.nextval fromorders");
行,应用程序会运行,但在保存记录时明显没有得到下一个序列。我尝试过只执行 .GenerateBy.Sequence("ORDERS_SQ");
但我似乎没有让任何东西正常工作。
谁能告诉我使用 Fluent NHibernate 正确获取下一个可用序列的正确方法?
我正在使用 Fluent NHibernate 1.1 和 NHibernate 3.0 Beta。
谢谢。
I'm using NHibernate / Fluent NHibernate with Oracle and I'm running into an issue. I've got the following mapping file defined:
public OrderMap()
{
Table("ORDERS");
Id(x => x.OrderId, "ORDER_ID").GeneratedBy.Sequence("select ORDERS_SQ.nextval from orders");
Map(x => x.CreatedBy, "CREATED_BY");
Map(x => x.OrderStatusCd, "ORDER_STATUS_CD");
Map(x => x.StoreGroupId, "STORE_GROUP_ID");
Map(x => x.IsActive, "IS_ACTIVE");
Map(x => x.OrderDate, "ORDER_DATE");
}
When I go to run my project I get the following error:
An invalid or incomplete configuration was used while creating a SessionFactory.
If I remove the .GeneratedBy.Sequence("select ORDERS_SQ.nextval from orders");
line, the application runs but I don't get the next sequence obviously when I save a record. I've tried doing just .GeneratedBy.Sequence("ORDERS_SQ");
but I just don't seem to get anything to work right.
Can anyone tell me the proper way to use Fluent NHibernate to get the next available sequence correctly please?
I'm using Fluent NHibernate 1.1 with NHibernate 3.0 Beta.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需指定序列的名称:
Just specify the name of the sequence: