0

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 ?

skaffman
  • 398,947
  • 96
  • 818
  • 769
gpasse
  • 4,380
  • 7
  • 44
  • 75
  • Bear in mind that Oracle table/column names are not case sensitive, so the camelCase won't be reflected in the database. RUNNINGWORDSTOGETHERMAKESITHARDTOREAD – Gary Myers Jun 27 '11 at 23:02

3 Answers3

5

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

Community
  • 1
  • 1
Ralph
  • 118,862
  • 56
  • 287
  • 383
2

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
abalogh
  • 8,239
  • 2
  • 34
  • 49
  • Thanks. I'll do that next time. But how is it with updating my project with new column name. I am pretty far into it now. I tried replacing all occurences of my colum name but I ran into lot of troubles... – gpasse Jun 27 '11 at 11:44
  • You have a Foo.java, in which your personName field is defined. There you should have a @Column annotation, change value of 'name'. – abalogh Jun 27 '11 at 11:47
0

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 ...