I'm probably making silly mistakes here, but I couldn't find the right documentation.
The problem is that I'm defining an association, but the reverse-engineering process ignores it.
SituationTable G913 is a legacy table; it has no primary key but a unique key over the fields WGR and FI_NR.
Table REICHW is a table I'm free to redesign as needed. It uses the fields RWWGR and RWABC as primary key (I'm stripping the true list of PK fields here for brevity).
G913 provides human-readable texts for WGR codes.
IntentI need to set up an association from REICHW to G913 so that the WGR texts become available.
As a JOIN condition, it would be written as
G913.WGR = REICHW.RWWGR AND G913.FI_NR = 1
My attemptsHere's my hibernate.reveng.xml (a pity that BBCode [ color ] doesn't work inside [ code ]):
Code:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-schema="ECHT" />
<table-filter match-name="HF_DI_.*" />
<table-filter match-name="G913" />
<table name="HF_DI_REICHW">
<foreign-key constraint-name="reichw_g913" foreign-table="G913">
<column-ref local-column="RWWGR" foreign-column="WGR" />
<column-ref local-column="1" foreign-column="FI_NR" />
<many-to-one fetch="join" />
</foreign-key>
</table>
<table name="G913">
<primary-key>
<key-column name="WGR" /><key-column name="FI_NR" /></primary-key>
</table>
</hibernate-reverse-engineering>
For some reason, Hibernate Tool doesn't generate anything from the <foreign-key> tag.
Final detailsI'm using Oracle 9i.
I'm using annotations, not generating .hbm.xml.
No association annotations are generated with or without the primary key definition for G913.
Association annotations and the corresponding fields and accessors
are defined for a pair of unrelated tables that have a database-defined foreign key constraint.
Any help appreciatedTop priority would be getting the thing to fly, but hints and tips on improving the above hibernate.reveng.xml would be appreciated as well.
TIA!