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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:56:37+00:00 2026-06-10T23:56:37+00:00

I am running a grails application and I am receiving the weirdest error I’ve

  • 0

I am running a grails application and I am receiving the weirdest error I’ve probably ever encountered. One “field” in a model got data that just disappears for no reason.

I have two Model or a Domain class in my project with the following set up:

class Insertion {

String title
Date insertDate

static hasMany = Dataholder

  static constraints = {
    title(unique: true)
  }
}



class Dataholder {

    String product
    int somenumber
    int somenumber2
    int somenumber3
    Date startDate
    Date endDate
    List<String> somedatalist
    Insertion insertions

    static belongsTo = Insertion

    static constraints = {
    }
}

The “insertion” class is representing every time a user might input a bunch of dataholders. The dataholder represents all the data for that specific product. Important to know is that the data that disappears is contained in the Dataholder model and the ONLY data that disappears is the somedatalist.

This is the magic which is completely confusing, when I insert the data and saves it. It all goes well:

if (!errors) {

            dataholderValidator.each {
                it.insertion = insertion
                it.save()
            }

        def results = Dataholder.findAllByInsertion(insertion)

I do some validating and apply data to every Dataholder and then if everything goes well, if(!errors) I add the insertion to each object. After that is done I save each objec, saving the data to the database. You may think it’s going wrong here but just wait and be amazed.

After saving I get all the Dataholders from the database (since I want to be sure that the data was saved before printing it out to the user) by using the insertion. This is where the strange part begin, what I get back is the correct data:

results.each {
                it.somedatalist.each { it2 ->
                    if(!weekdays.contains(it2))
                        weekdays.add(it2)
                }
            }

Populate an array with all the unique items from the datalist. Then printing it out to the view and voila:

the view with correct data

Now, we just wait for the users confirm of all the data in the view and when he or she is clicking on a confirm button the insertion title is sent with post to function which would retrieve the data and to my surprise the somedatalist is null.

This is the functionality that retrieves the data:

    def result = Insertion.findByTitle(insertionTitle)

    def results = Dataholder.findAllByInsertions(result)

When putting a breaking point after results I can for sure confirm that every Dataholder contains the correct the right data except that somedatalist which is equal to null.

I’ve tried to get the data above by using the Insertion Title instead of just using the object and it works well. I can’t understand why the data is populated in the database in one second and how something can just disappear?

Test:

void testSaveDataholder() {
        Insertions insertion = new Insertion(title: 'adadad', insertDate: new Date())
        insertion.save()
        assert Insertion.all.size() == 1
        Dataholder ed = new Dataholder(product:  'abc123', somenumber:  123, somenumber2: 13, startDate: new Date(), endDate: new Date(), somedatalist: ['TI'], insertions:  insertion)
        ed.save()
        assert Dataholder.all.size() == 1
        assert Dataholder.all.first().somedatalist.size() == 1
        assert Dataholder.all.first().insertions.title == 'adadad'
        assert Insertion.findAllByTitle('adadad').size() == 1
        assert Dataholder.findAllByInsertions(Insertion.all.first()).size() == 1
    }

This test all returns true, I am using Grails 2.1.

EDIT: I am using the in-memory database with “update” as configuration. So I can’t really view the data. But it should be there.

Please help me with your sage advice and better wisdom.

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

    It just has come to my mind. Persisting a collection of objects into single column breaks the 1st normal form, so it is not the correct way to do it. I have immediately googled an issue in JIRA:

    http://jira.grails.org/browse/GRAILS-1023

    The correct way is to create a new domain class with single String attibute and use standard one-to-many relation.

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

Sidebar

Related Questions

when i am running my grails application i am getting schemaUpdate fail error; hbm2ddl.SchemaUpdate
I am running a Grails application and it just gets stuck in the Configuring
I have a Grails web application running on a german localized machine. How does
I got Grails CMS (Weceem) up and running. Through the admin screen I have
I try to running a grails application in production mode, I see the tutorial
I am running an Integration Test for a Grails application. I am using the
Does anybody know how to (easily) rename an existing grails application? I'm running into
I'm running a grails script to load a bean from the grails application, however,
I am running a grails test run-app all day with my application and it
In my grails application running on tomcat 7, Somewhere I am invalidating the existing

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.