Grim
Grim

Reputation: 2040

Entity not saved

i created my domain-class via editor as usual, i create the controller and some views as usual too.

I use the ui as usual to create an database-entry as usual, and the .save() method returns true.

But no database-row has been insert to the database!

Any suggestions?

Upvotes: 0

Views: 183

Answers (3)

Grim
Grim

Reputation: 2040

It was an different Case

I found

static transactional = false

on the top of my class.

BS!

Upvotes: 0

Tomas Lin
Tomas Lin

Reputation: 3532

you might get more insight if you do save( flush:true, failOnError: true ). This will throw an exception and help you diagnose it if it is hibernate failing down the chain.

Also, you might want to make sure your database settings are right ( i.e., in-memory databases get wiped ). Do you see anything when you call Domain.list() afterwards?

Upvotes: 1

Alidad
Alidad

Reputation: 5538

Do something like this to your domain object and then print the errors. Save will refuse to save if there is any constraints violation.

def user = new User(params)

if (user.save()) {
   return user
}
else {
  user.errors.allErrors.each {
      println it
  }
}

Upvotes: 1

Related Questions