My Postgres db has mixed case table names. In my hibernate.properties I've added
hibernatetool.metadatadialect=com.xxx.util.hibernate.PostgreSQLMetaDialect
Code:
public class PostgreSQLMetaDialect extends JDBCMetaDataDialect {
private static final Log log = LogFactory.getLog(PostgreSQLMetaDialect.class);
public boolean needQuote(String name) {
log.debug("needQuote(" + name +")");
if(null != name && 0 != name.compareTo(name.toUpperCase())) {
return true;
} else {
return super.needQuote(name);
}
}
}
I have the following reveng.xml for Hibernate Tools 3.2.3.GA.
Code:
<hibernate-reverse-engineering>
<schema-selection match-schema="public"/>
<table-filter match-schema="public" match-name="employee_dept" package="com.xxx.domain.entity" exclude="false"/>
<table-filter match-schema="public" match-name="xref_employee_number_Contact" package="com.xxx.domain.entity" exclude="false"/>
<table-filter match-schema="public" match-name="CONT_Contact" package="com.xxx.domain.entity" exclude="false"/>
<table-filter match-schema="public" match-name="CONT_EmployeeHR" package="com.xxx.domain.entity" exclude="false"/>
<table schema="public" name="employee_dept">
<foreign-key constraint-name="employee_number_fk" foreign-table="CONT_EmployeeHR">
<column-ref local-column="employee_number" foreign-column="employee_number" />
<many-to-one property="getEmployee" exclude="false"/>
<set property="getDepartments" exclude="false"/>
</foreign-key>
</table>
</hibernate-reverse-engineering>
Any mixed case table that I want I am now able to filter. Classes and hbm.xml are created, but the foreign key definition in reveng.xml is ignored. The log says
DEBUG org.hibernate.cfg.reveng.JDBCReader - Table TableIdentifier(public.employee_dept) excluded by strategy
DEBUG org.hibernate.cfg.reveng.JDBCReader - User defined foreign key `employee_number_fk` references unknown or filtered table TableIdentifier(public.employee_dept)
Is it possible to override JDBCReader like I did for JDBCMetaDataDialect? Then I could bypass the condition. Is there another way around it?
Adding ticks didn't work, i.e "`employee_dept`".