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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:26:05+00:00 2026-05-18T22:26:05+00:00

Assume this snippet of Hiberante code: session.beginTransaction(); Event event1 = session.load(1); Event event2 =

  • 0

Assume this snippet of Hiberante code:

session.beginTransaction();
Event event1 = session.load(1);
Event event2 = new Event(2);
event2.setNextEvent(event1);
event2.save();
session.getTransaction().commit();

My question is, does this work as expected? That is, can I read something from the database, set it on another entity, and then save that entity to the database in a single transaction?

In other words, does beginning the transaction mean “I’ll collect all queries to the database, and hold on to them until you tell me to commit them.” orr does begin really just mean lock and commit means unlock?

  • 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-18T22:26:06+00:00Added an answer on May 18, 2026 at 10:26 pm

    I’ve read through your example several times and I cannot see what you are talking about. There are no changes or commits in the code and no indication of whats pending commit and whats not. If this code was was in a typical system making use of an ORM such as hibernate there would be no issue with it that I can see.

    Presuming that a has not been committed to the database, then dao.findBar(a) would still return it because it would be in hibernates caches. Presuming it has been associated with hibernates session in the first place.

    dao.findBar(a) should return x, providing it fits the same criteria as a. i.e. that it already exists or has been associated with the hibernate session.

    So therefore dao.findBar(x.getBaz()) should also work presuming the same sort of stuff.

    As you can see there is a lot of “presumably’s” in the above statements. I doubt you will get a better answer without a clearer question.

    A further complication is that your question doesn’t mention ORM’s, but you talk about them in the comments. Hence my comment assume that situation. If you are not using an ORM and your dao accesses a database directly through JDBC then the answers would be entirely different again – depending on the internal coding of the dao.

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

Sidebar

Related Questions

let's assume I have this snippet of the code: void foo_for_foo( void some_function(int, int))
I wrote this snippet of code and I assume len is tail-recursive, but a
Assume this code works: left '*' left '+' expr: expr '+' expr | expr
From the jQuery documentation on JavaScript types comes this snippet of code describing the
I've done this before, but can't find the sample code...still new to c++. I
Let's assume following code snippet: public class NotThatWellWrittenClass { public static void doSmth() {
Lets assume I have the following : 1- a code snippet CODE1 with time
Say I'm trying to execute this JavaScript snippet. Assume the undeclared vars and methods
I have a Fortran77 snippet that looks like this: DO 1301 N=NMLK-2,2,-1 Some code...
assume this following function: int binaryTree::findHeight(node *n) { if (n == NULL) { return

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.