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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:38:26+00:00 2026-06-11T02:38:26+00:00

I see that this error message has been posted several times already in the

  • 0

I see that this error message has been posted several times already in the context of hibernate.

I am getting this error while using grails service and a domain class, any help will be really appreciated

Domain class

class Coupon {
    Date dateCreated
    Date lastUpdated
    String code
    String email
    String address
    String state
    String city
    String zip
    def couponCodeGeneratorService

    def beforeValidate() {
        println code+"---------8-"
        code = couponCodeGeneratorService.generate()
        println code+"----------"
    }
    static constraints = {
        email blank:false,email:true
        address blank:false
        state blank:false
        city blank:false
        zip blank:false
    }
}

Service

class CouponCodeGeneratorService {
    Random randomGenerator = new Random()
    def serviceMethod() {

    }
    def generate(){
        def group1 =  randomGenerator.nextInt(9999)+"";
        def group2 =  randomGenerator.nextInt(9999)+"";
        def group3 =  randomGenerator.nextInt(9999)+"";
        def group4 =  randomGenerator.nextInt(9999)+"";
        return group1.padLeft(4,"0") +group2.padLeft(4,"0")+group3.padLeft(4,"0")+group4.padLeft(4,"0")
    }
}

The error I am getting is

---------8-
4844634041715590----------
4844634041715590---------8-
| Error 2012-09-10 11:32:54,938 [http-bio-8080-exec-7] ERROR hibernate.AssertionFailure  - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
Message: null id in com.easytha.Coupon entry (don't flush the Session after an exception occurs)
   Line | Method
->>  19 | beforeValidate     in com.easytha.Coupon
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    46 | onApplicationEvent in org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
|    24 | save . . . . . . . in com.easytha.CouponController
|   186 | doFilter           in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|    63 | doFilter . . . . . in grails.plugin.cache.web.filter.AbstractFilter
|   886 | runTask            in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . .  in     ''
^   662 | run                in java.lang.Thread
| Error 2012-09-10 11:32:54,944 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver  - AssertionFailure occurred when processing request: [POST] /EasyTha/coupon/save - parameters:
zip: asdf
address: asd
email: s.s@s.xom
state: asd
code: 
create: Create
city: asdf
null id in com.easytha.Coupon entry (don't flush the Session after an exception occurs). Stacktrace follows:
Message: null id in com.easytha.Coupon entry (don't flush the Session after an exception occurs)
   Line | Method
->>  19 | beforeValidate     in com.easytha.Coupon
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    46 | onApplicationEvent in org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
|    24 | save . . . . . . . in com.easytha.CouponController
|   186 | doFilter           in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|    63 | doFilter . . . . . in grails.plugin.cache.web.filter.AbstractFilter
|   886 | runTask            in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . . . . . . .  in     ''
^   662 | run                in java.lang.Thread

I am not very familiar with Hibernate, also is this a correct way to create a coupon code that looks like a credit card number?

  • 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-11T02:38:27+00:00Added an answer on June 11, 2026 at 2:38 am

    I suspect the problem may be that the CouponCodeGeneratorService is transactional. Therefore, when you call the service method from inside your beforeValidate you’re opening and closing a transaction (even though you don’t touch the database inside the method), which among other things will cause another flush of the session.

    Try making the service non-transactional:

    static transactional = false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see that this has been asked many times. But, unfortunately I have not
So I see that this question has already been asked, however the answers were
Has anyone encountered this error message recently while using FEDEX's shipping rate API?? I've
I see that many people get this error, but their situations all appear a
How can I resolved this error that I see in Gradle after upgrading to
A little background on this error: The customer getting this error message in their
This question has been asked many times before, but they all seem to relate
Update: Tried November CTP release. Same error message. Forgot to mention that this server
I feel like this question has been asked many times, but the solution is
I am new to RoR and I keep getting this error message: $ rake

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.