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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:58:09+00:00 2026-06-03T23:58:09+00:00

For a project I’m working on, i’m adding import/export functionality. This is working OK,

  • 0

For a project I’m working on, i’m adding import/export functionality. This is working OK, no issues.

What I’m trying to do now, is to have an option called “dryRun” which allows the user to test the import before actually doing anything, and just give an report back.

So, my setup is:

  1. Getting the import data through spring mvc (with OpenSessionInView)
  2. Deserialize this into my domain classes (which are the actual mapped hibernate classes)
  3. Scan through everything and make sure that references etc are ok.
  4. All my services have a @Transactional around them

This is mostly OK, but somewhere.. a save is triggered (i never call save), and my grouping object is complaining about a transient reference.. which is correct, since it is not saved.. I assume this is some kind of default mode hibernate has, since the grouping object references another object that is mapped.. So how can I make sure that hibernate never saves anything? without removing the @Transactional and OpenSessionInView (which is needed for the normal case)

Any ideas?

Regards,
Morten

  • 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-03T23:58:10+00:00Added an answer on June 3, 2026 at 11:58 pm

    You say

    somewhere.. a save is triggered

    That “somewhere” is in the stack trace which you get with the exception.

    [EDIT] The stack trace basically says “the method MetaDataController.importXml() is annotated with @Transactional”. When it returns, Hibernate tries to commit the transaction as it should and then, it stumbles over an unsaved dependency in OrganisationUnitGroup (and yes, it would be nice if it would say which field contains the dependency because Hibernate knows this, too).

    There are several solutions:

    1. Create two methods to import. The new one, .importXmlDryRun() must not have the @Transactional annotation. That might work but my gut feeling warns me about problems even though I couldn’t name them right now.

    2. Throw an exception in .importXml() to abort the transaction when dry run is requested and ignore this exception in the default handler. The exception will cause Hibernate to roll back. This is the safest solution.

    3. Get the hibernate session and call clear() (docs)

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

Sidebar

Related Questions

Project I'm working on uses jQuery. I have a series of Ajax calls being
The project is ASP.NET 2.0, I have never been able to reproduce this myself,
Project: ASP.NET 3.5 with C# I have this much :- A table which used
The project i am working at right now requires some declarative way of defining
A project I was working on has finished, so I've been moved on to
The project I'm currently working on generates 30+ warnings each time it gets build.
Eclipse project, I have Subversion set to ignore the bin directory, and also within
Project Euler I have recently begun to solve some of the Project Euler riddles.
Project Euler 126 says: If we then add a second layer to this solid
Project file here if you want to download: http://files.me.com/knyck2/918odc So I am working on

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.