Spring Roo Oracle 和 Underscore

发布于 2024-11-17 11:19:59 字数 160 浏览 6 评论 0原文

我有一个关于 spring roo 和数据库的问题。 我有一个名为 personName 的字段,在 oracle 中将列创建为 person_Name

我有一种方法可以避免使用下划线。我想命名我的列 personname 可以解决这个问题,但是我可以要求 spring 不要添加下划线吗?

I have a question concerning spring roo and databases.
I have a field called personName, in oracle to column is create as person_Name

I there a way to avoid the underscore. I suppose naming my column personname would fix this, but can I ask spring not to add the underscore ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

睡美人的小仙女 2024-11-24 11:19:59

如果您需要通用解决方案(而不是“修复”某些单点(abaloghs 答案)),您可以为 JPA 提供程序指定命名策略。

有关示例,请参阅:JPA (Hibernate) 和自定义表前缀

If you need a general solution (instead of "fixing" some single points (abaloghs answer)), you can specify a Naming Strategy for your JPA provider.

For an example see: JPA (Hibernate) and custom table prefixes

转角预定愛 2024-11-24 11:19:59

Roo 默认情况下引用 JPA 实现来确定列名称。您可以使用 --column 属性覆盖默认值:

entity --class Foo
field string --fieldName FooBar --column fooBar

Roo by default refers to the JPA implementation to determine column names. You can override the defaults with the --column property:

entity --class Foo
field string --fieldName FooBar --column fooBar
誰認得朕 2024-11-24 11:19:59

你好,
顺便说一句,我不认为可以对表名中带有下划线的数据库进行逆向工程:

  1. 由于 Java 接受类名中的下划线,因此将创建并编译相应的域类,
  2. 将在不引发任何问题的情况下执行测试,
  3. 一切都会作为 GUI 的脚手架,
  4. 您将成功将其部署在 tomcat 上,并且您的应用程序页面将显示在浏览器中。
  5. 您可以填写表单来创建对象的新实例
  6. ,但是如果您单击“保存”-->内部错误

如果您查看 tomcat 日志,您会发现众所周知的异常: javax.servlet.jsp.JspTagException: No message found under code ...

原因是您的类名已在 message_xx 中被截断。属性文件。
下划线之前的所有内容都被删除,因此找不到任何消息来显示您的记录已成功保存。

如果 ROO shell 在创建 jpa 实体时而不是在运行时抛出错误,那就太好了……

Bonjour,
by the way, I do not think that it is possible to reverse engineer a database with underscores in table names :

  1. the corresponding domain classes will be created and compiled since Java accept undersocres in class names
  2. the tests will be performed without raising any issue
  3. everything will be scaffold for the GUI
  4. you will succesfully deploy it on tomcat and your application page will show up in your browser
  5. You may fill the form to create a new instance of your object
  6. But if you click on SAVE --> internal error

If you have a look at the tomcat log, you will fid the well known exception : javax.servlet.jsp.JspTagException: No message found under code ...

The reason is that your class name has been truncated in the message_xx.properties files.
Everything before the underscore is dropped and thus, no message is found in order to display that your record has been successfully saved.

It would be nice that the ROO shell raise an error when the jpa entity is created and not at runtime ...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文