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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:30:17+00:00 2026-05-17T19:30:17+00:00

I am porting a Grails application from Oracle to MySQL database. The original Oracle

  • 0

I am porting a Grails application from Oracle to MySQL database. The original Oracle version is a legacy database which uses a few complex Views leveraging Oracle’s INSTEAD OF INSERT OR UPDATE feature which MySQL doesn’t have. As a workaround I have implement Insert and Update methods on the Domain classes which point to these kinds of Views. For example,

class AdminUser {
    //...
    def update() {
        if(this.validate()) {
            Sql sql = Utils.getHibernateSql()

            sql.execute(
                "update table_x ...",
                [...]
            )

            sql.execute(
                "update table_y ...)",
                [...]
            )

            sql.execute(
                "update table_z ...",
                [...]
            )

            return true
        }

        return false
    }
    //...
}

Here is a description of the problem I am running into at the moment:

  1. Within a service method I load an instance of AdminUser using AdminUser.get
  2. I modify the loaded instance and call update(), all appears well
  3. Once the service method finishes executing an exception is thrown due to something calling save on the instance.

How can I prevent the magical save happening in step (3) (I recently read somewhere that Grails will automatically save a modified Domain class instance which hasn’t yet been saved upon exiting a service method, but I can’t seem to find the link to that resource right now)?

  • 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-17T19:30:17+00:00Added an answer on May 17, 2026 at 7:30 pm

    You’re leaving the modified instance in the hibernate session with dirty fields. When the hibernate session gets flushed, it will try to save the object again with the usual save() method.

    One solution would be to discard your object from the hibernate session after you’ve manually saved the changes. For example:

    def update() {
        if(this.validate()) {
            Sql sql = Utils.getHibernateSql()
    
            sql.execute(
                "update table_z ...",
                [...]
            )
    
            ...
    
            this.discard()  // remove the object from the hibernate session
            return true
        }
    

    In addition, you can add this to your Config.groovy to require that objects be saved explicitly:

    hibernate.flush.mode="manual"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on my first Grails application, which involves porting over an old
While porting data from one mysql database to another there have come some issues
So I am porting a legacy application over from coldfusion to asp.net/c#. My problem
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
I am currently porting an application from iOS into Android and I have ran
I am porting visual c++ 6 application to python using ctypes. It uses same
I'm porting a C# application which is completely written in windows under Visual studio
I'm porting a rails app to grails that uses oauth to push messages to
Porting a Qt 4.6.3 application from Windows to Linux. The standard way to port
Porting over an application to use NHibernate from a different ORM. I've started to

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.