非持久实体与手动 POJO +查看 +控制器?
我已经使用 Roo 成功创建了一个基本的 Spring Web MVC 应用程序,我可以补充一下,这是一种享受!该应用程序使用持久性(HIBERNATE + HYPERSONIC_IN_MEMORY),这正是许多 POJO 所需要的。
现在,假设我想编写一些可以从视图端访问的自定义方法,例如日终计算或其他方法。我对如何实现这些的直接想法是
1) 创建一个实体,使其不使用持久性并实现此类所需的方法,依靠 MVC 脚手架进行演示
或
2) 创建 POJO + 视图 + 控制器手动
我最好的选择是什么? 1)是否可能(即不通过 roo 对实体使用持久性)?如果是这样:是否可以自由编辑 .java 文件,而 .aj 文件由 Roo 处理?
提前致谢!
I've successfully created a basic Spring Web MVC application using Roo, which I might add, was a treat! The application uses persistence (HIBERNATE + HYPERSONIC_IN_MEMORY), which is what you'd want for many POJOs.
Now, suppose I'd like to write some custom method which is to be accessed from the View-side, like end-of-day calculations or what have you. My immediate thoughts about how to implement these are either
1) Create an entity, keep it from using persistence and implement the desired method(s) for this class, rely upon MVC-scaffolding for presentation
or
2) Create the POJO + View + Controller manually
What is my best alternative? Is 1) even possible (i.e. not using persistence for entities through roo)? And if so: is it so that the .java files may be freely edited, while the .aj files are handled by Roo?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Roo 的
entity
命令,选项 1 绝对没问题。您可以在 Roo shell 中创建新实体,然后执行脚手架,没有任何问题。然后您也可以毫无问题地编辑您的 *.java 部分。唯一的建议是在编辑时保持 Roo shell 运行。Option 1 is absolutely Ok using Roo's
entity
command. You can create new entity in Roo shell and then perform scaffolding without any problem. And then you can edit your *.java part without problems too. The only recommendation is to keep Roo shell running while editing.