After years of JDBC, I've finally been given a chance to take the Hibernate plunge! We have a legacy database that resides on an AS/400 for which I'm generating entity and dao code using Hibernate 3.3.1 and the Hibernate Tools 3.2.3 plug-in for Eclipse 3.4.
The following is a snippet of a Subscriber.reveng.xml file I've built:
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>
<table-filter match-catalog="OUR_CATALOG" match-schema="CUSTFILES" match-name="CUSTOMERDB"/>
<table catalog="OUR_CATALOG" schema="CUSTFILES" name="CUSTOMERDB" class="Subscriber">
<primary-key>
<generator class="native"/>
<key-column name="RECORDID" property="id" type="long"/>
</primary-key>
<column name="RECSTS" property="RecordStatus"/>
<column name="CO#" property="CompanyNumber"/>
<column name="CYCLE#" property="CycleNumber"/>
<column name="BACCT#" property="AccountNumber"/>
<column name="BDCYY" property="DisconnectYear"/>
<column name="BDCMM" property="DisconnectMonth"/>
<column name="BDCDD" property="DisconnectDay"/>
<column name="FNAME" property="FirstName"/>
<column name="LNAME" property="LastName"/>
<column name="TYPSER" property="ServiceType"/>
<column name="ADLN1" property="AddressLine1"/>
<column name="ADLN2" property="AddressLine2"/>
<many more columns . . ./>
</table>
</hibernate-reverse-engineering>
Among others, I used the reverse engineering feature of Hibernate Tools as part of my pro-Hibernate argument to persuade my employer to let me have a go at it. But to my disappointment, the customizations I've added to my Subscriber.reveng.xml file seem to have no effect whatsoever on the source code produced via Hibernate Tools & Eclipse.
The class specified in <table> is ignored so that the entity classes produced are Customerdb, CustomerdbHome, and CustomerdbId with every single field in the table defined as part of a composite key (the table in question has no unique key).
The customizations I've added for the column-to-property relationships and the primary key definition are also ignored. I realize that I can refactor the names, etc., but if I understand
Java Persistence with Hibernate correctly, this should work. I thought maybe this behavior was specific to the AS/400, but I tried it using a very simple MySQL db with the same results.
What am I missing???
thanks in advance,
dgg