Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell Hibernate annotation @Column to be case-sensitive?

I'm trying to do a simple SELECT query in a table named ECM (in uppercase) on a Sybase db with Hibernate. I've annotated my DBO this way :

@Entity
@Table(name="ECM")
public class RelationshipDbo {
    ...
}

However, I'm facing a "table not found" error : the generated SQL has the table name in lowercase. I cannot change the database configuration to tell it to be case-insensitive.

I've also tried putting quotes like this :

@Table(name="`ECM`")

and this :

@Table(name="'ECM'")

Result : the quotes are added in the query, but the table name is still converted from uppercase to lowercase.

Technical information :

Hibernate 4.3
JPA 1.2
org.hibernate.dialect.SybaseDialect

Have you guys any idea?

EDIT: Also tried this Hibernate changes @Table(name) to lowercase

Then my columns names and table name are automatically quoted, but the names still get lowercased.

like image 911
Deathtiny Avatar asked Oct 21 '22 12:10

Deathtiny


1 Answers

I think I have your answer:

Basically, you need to change the naming strategy for you JPA provider. How you do this will depend on how you setup your project.

In my case, using spring boot data I set a property in my application.properties to

spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.EJB3NamingStrategy

Without more details from you I can't give more specifics on how to do this.

like image 174
Christian Bongiorno Avatar answered Nov 01 '22 15:11

Christian Bongiorno