Reputation: 748
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.
Upvotes: 5
Views: 21112
Reputation: 529
My goal is a little different since was trying to create tables upper case and hibernate created them in lower case. Also i was using MySQL not Sybase. But for me quoting the names like this worked:
@Entity
@Table(name="\"ECM\"")
public class RelationshipDbo {
...
}
Then tables were created upper case. Maybe that helps also for the queries.
Upvotes: 3
Reputation: 5648
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.
Upvotes: 1
Reputation: 5700
Try this:
Use backticks as in @Table(name="`ECM`")?
This must work from Hibernate point. If not then problem should be in DB (if i'm not wrong)
Upvotes: 0
Reputation: 1097
What is your Sybase db version ?
SybaseDialect
has been deprecated in Hibernate 3.5 and then refactored since Hibernate 4.1 with a bunch of subclasses matching different versions of Sybase. Have you tried one of the subclasses to see if it makes any difference?
Upvotes: 0