Announcement Announcement Module
No announcement yet.
JSON create/update/delete is not works Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSON create/update/delete is not works

    roo script:
    project --topLevelPackage com.cci.iot
    jpa setup --provider HIBERNATE --database MYSQL --databaseName test --userName root --password test
    entity jpa --class ~.domain.Topping --testAutomatically
    field string --fieldName name --notNull --sizeMin 2
    entity jpa --class ~.domain.Base --testAutomatically 
    field string --fieldName name --notNull --sizeMin 2
    entity jpa --class ~.domain.Pizza --testAutomatically 
    field string --fieldName name --notNull --sizeMin 2
    field number --fieldName price --type java.lang.Float
    field set --fieldName toppings --type ~.domain.Topping
    field reference --fieldName base --type ~.domain.Base
    entity jpa --class ~.domain.PizzaOrder --testAutomatically 
    field string --fieldName name --notNull --sizeMin 2
    field string --fieldName address --sizeMax 30
    field number --fieldName total --type java.lang.Float 
    field date --fieldName deliveryDate --type java.util.Date
    field set --fieldName pizzas --type ~.domain.Pizza
    perform tests
    json all
    web mvc json setup
    web mvc json all --package ~.json
    When I use "list" or "show" command, it works well:
    curl -i -H "Accept: application/json" http://localhost:8080/RJ2/bases
    curl -i -H "Accept: application/json" http://localhost:8080/RJ2/bases/82
    But When I use "create/update/delete" command, there are some problems, here is the "create":
    flexjson.JSONException: [ ]: Don't know how to bind {name:Thin Crust} into class com.cci.iot.domain.Base. You might need to use an ObjectFactory instead of a plain class.
    curl -i -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{"name":"Thin Crust"}'
    And "update/delete":
    Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.cci.iot.domain.Base#2];
    curl -i -X DELETE -H "Accept: application/json" http://localhost:8080/RJ2/bases/2
    I'm a new user of Roo and I've downloaded the latest release roo-1.2.3.RELEASE. I build the project only use roo script.

  • #2
    now I konw why.

    first, wrong syntax with JSON. '{"name":"Thin Crust"}' not works. "{name:Thin Crust}" is the right way.
    second, the record I want to delete, must create by progame that bulided by roo script. If I add it to database manually, it also can't be deleted.