Skip to content Skip to sidebar Skip to footer

Grails Save() Domain Object Actually Does A Select?

I am trying to take a JSONObject I posted to my groovy controller. I can pass the object, see the JSON data and then create a Domain Object out of it. When I save it to write to

Solution 1:

Looks like you have a unique constraint on username. Grails does a select to check uniqueness since assumed that reading one row is a lightweight action and it's preferable to triggering a unique constraint violation and exception.

An alternative is to remove the unique constraint in the domain class and add the unique constraint manually in the database.


Solution 2:

Did you tried something like :

Customers cust = new Customers(input);
println ("cust = "+cust);
cust.save();

Post a Comment for "Grails Save() Domain Object Actually Does A Select?"