Bartek Szczypien
Bartek Szczypien

Reputation: 343

Hibernate 5 - naming strategy - explicit names - capital letters are ignored

I try to set my JPA mapping. For some reasons i have to have the same java variable / table column names (including capital letters) but i cant set the hibernate up. I tried with explicit column names:

@Type(type="java.lang.Integer")
@Column(name = "nextInvoiceNr")
public int nextInvoiceNr;

and with implicit mapping:

@Type(type="java.lang.Integer")
public int nextInvoiceNr;

Both of those methods create column name without upper letters - "nextinvoicenr".

I also tried to change hibernate configuration adding there:

lConf.setProperty("hibernate.implicit_naming_strategy", "org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl");
lConf.setProperty("hibernate.physical_naming_strategy", "org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl");

but without success

Upvotes: 0

Views: 1003

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521804

I just answered what may be a very similar question to this one, which concerned an error stemming from using hyphens in the column name with Hibernate. The solution there, which may be applicable here, is to escape the column name in quotes:

@Type(type="java.lang.Integer")
@Column(name = "\"nextInvoiceNr\"")
public int nextInvoiceNr;

If you are using JPA 1.0, then you can escape the column name in backticks:

@Column(name = "`nextInvoiceNr`")

Of course, the alternative to this would be to not rely on case sensitive column names.

Upvotes: 1

Related Questions