Grails/MongoDB Why is this field not being saved to the db?

60 views Asked by At

I have the following Domain Classes:

class Account {

    String id    
    String email
    ...
    Ban ban

    static constraints = {
        ban nullable: true
    }

    static embedded = ['ban']
}

class Ban {
   Date dateBanned
   Account bannedBy
}

When i try to create a Ban and saved it in the account, only the dateBanned gets added to the database.

def ban = new Ban()
ban.bannedBy = springSecurityService.currentUser
ban.banDate = new Date()
account.ban = ban
account.save()

The result is an account with a field ban, but inside only one field, dateBanned, and not bannedBy.

I'm using Grails 2.3.7 (yes i know its dated but have no choice right now)

Is this because it's an account inside an account? Because i have other Classes with Accounts there that work perfectly.

0

There are 0 answers