Reputation: 1424
I'm Building and web App using the Spring Roo Tool. and while creating my classes via the roo shell console, I've used several times the option -permitReservedWords
to create some classes (e.g. Role, Group and User).
After generating the CRUD Views, I get this exception :
"org.hibernate.exception.SQLGrammarException: could not prepare statement"
Then I realized that the problem occurs only for entities with reserved Names, so How can I force these entities name, if it's not possible how can I edit the names, because the refactor option in eclipse doesn't solve the problem, especial with a lot of AspectJ Files in the projects ...
Upvotes: 1
Views: 11692
Reputation: 1973
Note the JPA default table name is the name of the class (minus the package) with the first letter capitalized, this is why you need -permitReservedWords
. Your entities User, Role, etc by default will be stored in User, Role, etc tables that are reserved words in almost all databases.
To change the default behaviour, use the annotation "@Table(name="app_user")" (javax.persistence.Table) to specify/customize the database table name that stores the data of given Entity. For example, User entity could be stored in uzer table.
Upvotes: 2