开发者

Spring Roo does not generate CRUD

In Spring Roo I used this tutorial with my custom xsd to generate objects.

After that I used command controller all ~.web, controller is generated but without CRUD functions.

If I make manual objects in Roo controller with CRUD functions is generated. Any idea what 开发者_开发问答is the problem?

Schema file xsd is in my case important for REST data exchange.


The tutorial you're referring to indeed explains how you can create a Java (domain) model based on a provided xml Schema, but the controller all ~.web command currently (version 1.1.0) only creates controllers and corresponding CRUD functions for actual Roo (database) entities. As the generated Java classes are not marked as Roo entities, the controller command will not create the by you expected CRUD commands, which it, as you stated, will do for manually created entities as these are marked as Roo entities (see the @RooEntity annotation on these).

As the tutorial also states, you will need to manually update your controller and view (*.jspx) files to implement the CRUD functionality when you use the Spring Roo jaxb addon. I know, from checking the forum and Jira issues, that there are currently some ideas on also having Spring Roo create basic CRUD functionality for normal (none-entity) beans (see issue ROO-344 and it's related ROO-277 issue), but these are currently only ideas and most likely won't be implemented within the near future. So, when using a XML schema as base for your Spring Roo domain model, you'll still need to do quite a bit of manual coding to have a basic CRUD application, as opposed to using a database as your base for generating your domain model, as it then basically is executing a couple of commands in the Roo shell and you're done.

If your XML schema is but a definition of your domain model and you actually do want your data to be stored in and retrieved from the database by your application, as oposed to call a REST webservice for retrieving and storing changes, you might try to use the jaxb addon to generate the model and then annotate the generated classes, but as I haven't done that myself before, I'm not sure if that will work, but it might be worth trying.


Spring Roo generates AspectJ (.aj) files next to the .java source files. So, you won't see the methods in your source files. They are in the .aj files but are present after compile in the generated .class files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜