I'm using Roo 1.1.5, with Eclipse STS, here is what I do: I create a new Spring Roo Project from Eclipse, and in the Roo Shell, I type the following:
persistence setup --provider DATANUCLEUS --database H2_IN_MEMORY
entity --class ~.domain.Task
field string --fieldName description --notNull --sizeMin 3 --sizeMax 512
field boolean --fieldName completed --notNull
controller all --package ~.controller
A more verbose description is in my blog, but what reported above is basically what I do.
In a web browser I can create and list tasks just fine, but if I try to edit (update) a Task, instead a new duplicated task is created... Possible that a bug like this has slipped in? Or is it something I'm doing wrong?
UPDATE: to be faster I've run the script from the command line and tried with all persistence providers.
$ roo
roo> project --topLevelPackage task --java 6 --projectName Task
roo> persistence setup --provider DATANUCLEUS --database H2_IN_MEMORY
roo> entity --class ~.domain.Task
roo> field string --fieldName description --notNull --sizeMin 3 --sizeMax 512
roo> field boolean --fieldName completed --notNull
roo> controller all --package ~.controller
roo> exit
$ mvn tomcat:run #or mvn jetty:run
Here are the results:
DATANUCLEUS AND DATANUCLEUS_2 WITH H2
Roo + Datanucleus + H2 results in a buggy application, updating results in duplicated records.
ECLIPSELINK WITH H2
Build failure
The following artifacts could not be resolved: org.eclipse.persistence:eclipselink:jar:2.2.0, org.eclipse.persistence:javax.persistence:jar:2.0.3: Could not find artifact org.eclipse.persistence:eclipselink:jar:2.2.0 in spring-maven-release (http://maven.springframework.org/release)
OPENJPA WITH H2
Works, with warnings. Example:
WARN [main] openjpa.Runtime - An error occurred while registering a ClassTransformer with PersistenceUnitInfo: name 'persistenceUnit', root URL [file:/home/stefano/workspace/task4/target/classes/]. The error has been consumed. To see it, set your openjpa.Runtime log level to TRACE. Load-time class transformation will not be available.
HIBERNATE WITH H2
works
DATANUCLEUS WITH GOOGLE APP ENGINE
Works...
project --topLevelPackage task --java 6 --projectName Task
persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE \
--applicationId appid
entity --class ~.domain.Task
field string --fieldName description --notNull --sizeMin 3 --sizeMax 512
field boolean --fieldName completed --notNull
controller all --package ~.controller
exit
mvn gae:run
Are you perhaps hitting this JIRA ROO-1467. The JPA spec leaves many things open to interpretation. In DataNucleus 3 there is a flag to get various different types of behaviour for merge to cater for all eventualities.
I have tryed your script (but I used Hibernate instead of datanucleus because of some not found dependencies). But it worked for me with out any problem.
So may the problem is datanucleus releated, or it "outside" of this script.