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 316799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:25:01+00:00 2026-05-12T08:25:01+00:00

NHibernate allows me to query a database and get an IList of objects in

  • 0

NHibernate allows me to query a database and get an IList of objects in return. Suppose I get a list of a couple of dozen objects and modify a half-dozen or so. Does NHibernate have a way to persist changes to the collection, or do I have to persist each object as I change it?

Here’s an example. Suppose I run the following code:

var hql = "from Project";
var query = session.CreateQuery(hql);
var myProjectList = query.List<Project>();

I will get back an IList that contains all projects. Now suppose I execute the following code:

var myNewProject = new Project("My New Project");
myProjectList .Add(myNewProject);

And let’s say I do this several times, adding several new projects to the list. Now I’m ready to persist the changes to the collection.

I’d like to persist the changes by simply passing myProjectList to the current ISession for updating. But ISession.SaveOrUpdate() appears to take only individual objects, not collections like myProjectList. Is there a way that I can persist changes to myProjectList, or do I have to persist each new object as I create it? Thanks for your help.

David Veeneman

Foresight Systems

  • 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-12T08:25:01+00:00Added an answer on May 12, 2026 at 8:25 am

    If you load objects like in your example – then yes you have to persist them one by one.

    However, if you make a small design change, and load something like : Account that has an IList<Project> – if you specify cascade “what_cascade_you_need” in the mapping , then when you change the projects on Account , you only have to save Account and everything will get saved.

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

Sidebar

Related Questions

I have a stored proc mapped as follows in NHibernate: <sql-query name=HistoricSearch> <return class=ResultItem>
We have a form which allows users to specify criteria to query a database.
Configuring NHibernate to display executed SQL does what it's supposed to, but whenever a
Does nHibernate create code that has all the details of the column? I know
I'm doing a simple query on the database, a search on two columns. I
Where I'm working, we have multiple database we need to be able to query.
I'm using DDD and NHibernate to persist my domain object. In my database every
I am looking for a way to query a Hibernate database with an external
I have read somewhere (can't remeber where and how) that NHibernate 3 allows the
I am trying to reproduce a query using the Nhibernate Criteria API and cannot

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.