I've been blessed with a Postgres DB with mixed case table names.
Normally, back ticks (`) can be added when a mixed case table name is needed, i.e. name="`mixedCaseTableName`"
If I use back ticks in @JoinTable, like this
Code:
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name = "`xref_employee_number_Contact`", schema="public",
joinColumns = @JoinColumn(name = "employee_number"),
inverseJoinColumns = @JoinColumn(name = "`CONT_ContactID`"))
public ContContact getContContact() {
return contContact;
}
then I receive the following error.
org.hibernate.AnnotationException: Cannot find the expected secondary table: no xref_employee_number_Contact available for com.ro.domain.entity.EmployeeDept
If no back ticks are included in @JoinTable, like this
Code:
@ManyToOne(fetch = FetchType.LAZY)
@JoinTable(name = "xref_employee_number_Contact", schema="public",
joinColumns = @JoinColumn(name = "employee_number"),
inverseJoinColumns = @JoinColumn(name = "`CONT_ContactID`"))
public ContContact getContContact() {
return contContact;
}
then my generated sql looks like this. It doesn't work because xref_employee_number_Contact should be quoted.
Code:
select
this_."ID" as ID1_7_13_,
this_."CONT_PersonID" as CONT2_7_13_,
this_."CONT_val_ContactRoleID" as CONT3_7_13_,
this_.crm_individual_id as crm4_7_13_,
this_.crm_userid as crm5_7_13_,
this_1_.employee_number as employee0_6_13_
from
public."CONT_Contact" this_
left outer join
xref_employee_number_Contact this_1_ on this_."ID"=this_1_."CONT_ContactID"
where
this_."ID"=60
I'm using Hibernate 3.6.0.Final
Are there any workarounds so the table name will be quoted in the sql? Thanks for your help.