如何正确使用Fluent NHibernate获取Oracle中的下一个Sequence?

发布于 2024-10-01 03:28:32 字数 858 浏览 1 评论 0原文

我正在将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

々眼睛长脚气 2024-10-08 03:28:33

只需指定序列的名称:

Id(x => x.OrderId).Column("ORDER_ID").GeneratedBy.Sequence("ORDERS_SQ");

// Real working code:
Id(x => x.Id).GeneratedBy.Sequence("SEQ_Catalog1");

Just specify the name of the sequence:

Id(x => x.OrderId).Column("ORDER_ID").GeneratedBy.Sequence("ORDERS_SQ");

// Real working code:
Id(x => x.Id).GeneratedBy.Sequence("SEQ_Catalog1");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文