开发者

Spring Roo + Hibernate: uppercase database name in the query

开发者 https://www.devze.com 2023-04-02 20:56 出处:网络
I\'ve reverse engineered a sample MySQL database with Spring Roo, and I\'m trying to insert a record using the Customer entity in this way:

I've reverse engineered a sample MySQL database with Spring Roo, and I'm trying to insert a record using the Customer entity in this way:

Customer customer = new Customer();
customer.setFirstName("Raffaello");
customer.setLastName("Baresi");
customer.persist();

However, while the initial connection to the database the insert query fails, so I've enabled the full query log and I've noticed that the schema name is uppercased as ROO_CRM instead of roo_crm.

insert into ROO_CRM.CUSTOMER (COMPANY_ID, FIRST_NAME, LAST_NAME) 
values (null, 'Raffaello', 'Baresi')

My database.property file contains the lower case name:

database.url=jdbc\:mysql\://localhost/roo_crm?zeroDateTimeBehavior\=convertToNull&characterEncoding\=UTF-8

While the generated Customer class has an upper case schema attribute of the @RooEntity annotation:

@Roo开发者_高级运维JavaBean
@RooToString
@RooEntity(versionField = "", table = "CUSTOMER", schema = "ROO_CRM")
@RooDbManaged(automaticallyDelete = true)
public class Customer {
}

I thought to lower case the schema name, clean and rebuild for added precaution, but the schema is still upper case in the query. I've also noticed that the Spring-managed Customer_Roo_Entity has the following line:

declare @type: Customer: @Table(name = "CUSTOMER", schema = "ROO_CRM");

Which is still with the upper case schema, but I'm not allowed to edit that file. What is the correct procedure to solve the problem?


It was actually very trivial solution: it was correct to change the schema attribute of the @RooEntity annotation. What I forgot is that, I should have left the roo shell open and that would have automatically modified the generated Customer_Roo_Entity.aj file.

I started the roo shell and the generated Customer_Roo_Entity.aj was modified and everything worked.

0

精彩评论

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

关注公众号