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

  • Home
  • SEARCH
  • 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 3214614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:04:54+00:00 2026-05-17T15:04:54+00:00

I have a mapping like this <class name=UserFileSummary table=UserFile lazy=false> <id name=FileId column=UserFileId type=int>

  • 0

I have a mapping like this

<class name="UserFileSummary" table="UserFile" lazy="false">
   <id name="FileId" column="UserFileId" type="int">
      <generator class="identity" />
   </id>...

and a property in the c# object like this

public long FileId { get; set; }

What I don’t understand is why when I get an instance using

var myFile = session.Get<UserFileSummary>(id)

change a field value and then save it like this

myFile.myProperty = newValue
session.Save(myFile)

I get an error saying the the Id have been altered from 1 to 1. There are some posts around about this, but this is a simple int column (identity 1, 1). I must have made some basic error, please can anyone help out. Thanks

I’ve added this bit as an edit as the question turns out to be a non question

The FileId property is type long, and the mapping is type int, that is why altered from 1 to 1 is a problem.

Please give me some feedback if you want me to delete this question, thanks everyone 🙂

  • 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-05-17T15:04:54+00:00Added an answer on May 17, 2026 at 3:04 pm

    The error in my case was due to the data type being a long (int64) in the database and being mapped to an int (int32) in the mapping. This meant that the real value changed whenever the object was saved, thus breaking the identifier. Thanks to everyone who helped out.

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

Sidebar

Related Questions

If I have a mapping like this: <class name=Users table=users> <id column=id name=id> <generator
I have a hibernate mapping as follows: <hibernate-mapping> <class name=kochman.elie.data.types.InvoiceTVO table=INVOICE> <id name=id column=ID>
I have a relation mapping table like this: attributeid bigint productid bigint To clean
I have a hierarchical structure like this: class Node { Node Parent; string Name;
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error
I have the following Hibernate Mapping, which has to be mapped using the Table
I have two table Part and SubPart. Part table has general fields like id,
I have a mapping application that needs to draw a path, and then display

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.