
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
Hi all,
I'm having a bit of trouble with a domain class I
have.
The code looks like this:
class Task {
String
code
String title
String
description
def beforeInsert =
{
code = "task-" + (Task.count() +
1)
}
static
constraints = {
title(blank:
false)
description(blank:
true)
code(nullable:true)
}
}
And my test looks like this:
void testCreateTask()
{
Task task = new Task(title:
'Task', description: 'This is a task').save()
assertEquals("task-1", task.code)
assertEquals("Task", task.title)
assertEquals("This is a task", task.description)
}
Removing the 'beforeInsert' and the corresponding
assert statement doesn't result is this exception. When I also add a new line to
the test case, (new Task.save(), which doesn't save because the title
constraint), the test works. I'm a bit lost here! What I did experience
btw, was that by setting the transactional flag to false, this exception also
did not occur. So my best guess is that something went wrong during a rollback
of the transaction, though I'm not sure.
Before making a JIRA for it, I though let's ask if
I'm doing something wrong here.
Thanks,
Erik