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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:33:35+00:00 2026-06-12T18:33:35+00:00

Just a simple Question with a Car-entity persisted field color of value red: 00

  • 0

Just a simple Question with a Car-entity persisted field color of value red:

00  @Transactional public class MyBean{...
01    public void test(){
02        Car c = s.find(Car.class,1);
03        c.setColor("blue");
04        test1(c);
05        System.out.println(c.getColor());   
06    }
07    @Transactional(readOnly=true)
08    public void test1(Car c){
09        c.setName("black");
10    }
11  }

Assuming, we are in Spring ORM TX-Transactional-Annotation environment, with transactional semantics and transaction scoped persistence context.

What will be printed to Console?

  • red
  • blue
  • black
  • 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-12T18:33:37+00:00Added an answer on June 12, 2026 at 6:33 pm

    Assuming transactional semantics are enabled when calling methods of the same instance and NESTED transaction propagation:
    It depends on the scope of the persistence context.

    Assuming a transaction scoped persistence context:
    black is printed to the console. The car instance is detached, because it was fetched outside the readonly transaction and is not merged into the readonly transaction. Calling the setter on a detached instance is safe (like the call to setColor("blue").

    Assuming an extended scope of the persistence context:
    black is also printed. From the javadoc of @Transactional

    If

    A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.

    And from the JPA 2.0 Spec Section 2.4.1.2 Mapping of Derived Identities:

    The embedded id attributes that correspond
    to the relationship are treated by the provider as “read only”—that is, any updates to them on
    the part of the application are not propagated to the database.

    But I’m not 100% sure, if there isn’t an exception thrown. Since the color property isn’t an embedded id the behaviour may vary.

    If transactional semantics are available via proxies then see the answer of Adrian Shum

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

Sidebar

Related Questions

Just a simple question: if I had a simple vector class: class Vector {
Just a simple question. Is it possible to change the text color of UITextView
Just a simple question, Im trying to replace class with var, but obviously still
Just a simple question : when should I use the term 'class', and when
just a simple question here. How can I get the return value on this
Just a simple question: I have read that a class should be made static
Just a simple question. I am looking at some javascript code here: <script class=brush:
just a simple question on a wx.TextCtrl element. i have this text field where
Just a simple question, but can't get an answer on my own. In memory
Just a simple question from a relative Java newbie: what is the difference between

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.