Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:28:40+00:00 2026-06-11T22:28:40+00:00

I have the following 2 mappings: internal RulesEngineHeaderMap() { Table(LIOEP023); CompositeId() .KeyProperty(x => x.CompanyCode,

  • 0

I have the following 2 mappings:

internal RulesEngineHeaderMap()
{
    Table("LIOEP023");

    CompositeId()
        .KeyProperty(x => x.CompanyCode, "CONO23")
        .KeyProperty(x => x.RuleID, "RLID23");
    Map(x => x.RuleGroup, "RGRP23")
        .Length(30)
        .Not.Nullable();
    Map(x => x.RuleDescription, "RLDS23")
        .Length(50)
        .Not.Nullable();
    Map(x => x.Expression, "EXPR23")
        .Length(2500)
        .Not.Nullable();
    HasMany(x => x.RuleVariables)
        .KeyColumns.Add("CONO24", "RLID24");
}

and

internal RulesEngineVariableDetailMap()
{
    Table("LIOEP024");
    CompositeId()
        .KeyProperty(x => x.CompanyCode, "CONO24")
        .KeyProperty(x => x.RuleID, "RLID24")
        .KeyProperty(x => x.Name, "RVAR24");
    Map(x => x.Type, "VTYP24")
        .Not.Nullable();
    Map(x => x.Description, "VDES24")
        .Not.Nullable();
    Map(x => x.Required, "RMAN24")
        .Not.Nullable();
    References(x => x.RuleHeader)
        .Columns("CONO24", "RLID24")
        .NotFound.Ignore()
        .Nullable();
}

When I try and add a new object into the RuleVariables IList of RulesEngineHeader and update, I get the error

Batch update returned unexpected row count from update; 
  actual row count: 0; expected: 1

When I look at my SQL, I’m seeing this:

SELECT rulevariab0_.CONO24 as CONO1_1_,
    rulevariab0_.RLID24 as RLID2_1_,
    rulevariab0_.RVAR24 as RVAR3_1_,
    rulevariab0_.CONO24 as CONO1_1_0_,
    rulevariab0_.RLID24 as RLID2_1_0_,
    rulevariab0_.RVAR24 as RVAR3_1_0_,
    rulevariab0_.VTYP24 as VTYP4_1_0_,
    rulevariab0_.VDES24 as VDES5_1_0_,
    rulevariab0_.RMAN24 as RMAN6_1_0_
FROM   LIOEP024 rulevariab0_
WHERE  rulevariab0_.CONO24 = 'LO' /* @p0 */     <-- KEY FIELD
    and rulevariab0_.RLID24 = 'Test' /* @p1 */  <-- KEY FIELD

The where clause only contains 2 of the 3 key fields that I defined, so it’s finding the record and trying to update, but then the update looks like this:

UPDATE LIOEP024
SET    CONO24 = 'LO' /* @p0_0 */,
    RLID24 = 'Test' /* @p1_0 */
WHERE  CONO24 = 'LO' /* @p2_0 */         <-- KEY FIELD
    AND RLID24 = 'Test' /* @p3_0 */      <-- KEY FIELD
    AND RVAR24 = 'Some Name' /* @p4_0 */ <-- KEY FIELD

As you can see, it’s using all 3 of the key fields. It should be doing an insert here instead, but since the select above found the record, it thinks it should do an update, which is returning 0 records.

Any ideas what I’m doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:28:42+00:00Added an answer on June 11, 2026 at 10:28 pm

    You are using a composite key for RuleVariable. NHibernate has no way of knowing whether your RuleVariable is a new instance or an existing one. If you used a generated id like identity, then it could tell by checking whether the id was > 0.

    You need to tell NHibernate that your new RuleVariable is a new instance, ie. you need to persist the RuleVariable before you save the Header, to do so, call session.Save(variable)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MetaMap files have following lines: mappings([map(-1000,[ev(-1000,'C0018017','Objective','Goals',[objective],[inpr],[[[1,1],[1,1],0]],yes,no)])]). The format is explained as mappings( [map(negated overall
I have the following mappings: public AccountMap() { Id(x => x.AccountId, AccountId).Column(AccountId); Map(x =>
I have the following mapping: <hibernate-mapping package=server.modules.stats.data> <class name=User table=user> <id name=id> <generator class=native></generator>
I have the following mapping for my table in MySql: <class name=Tag, namespace table=tags
I have the following mapping: public class LogEntryMap { public LogEntryMap() { Map.Id(x =>
I have the following mapping: @Entity @Table(name = Prequalifications) public class Prequalification implements Serializable
Lets say I have the following mapping: <hibernate-mapping package=mypackage> <class name=User table=user> <id name=id
I have the following code in my context, and no explicit table-class mapping, yet
I have the following classes and fluent mappings: public class A { public virtual
I have a Java Web application that has several servlets with the following mappings.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.