max wrote:
i think the issue is that you are using jdbcconfiguration + also includes and already existing mapping of that class and thus confuses hibernate.
Why do you have that fileset in there under <jdbcconfiguration> ?
Max - yup, I think you nailed it. I switched my hbm2java task back to using a plain old <configuration> instead of a <jdbcconfiguration>, and it seems to be happy again. I don't remember why I did that... must've been something I tried while I was thrashing helplessly to fix a separate problem (below):
Our database schema kinda sucks, and we have FK's which refer to other tables with compound PK's, and the FK constraints don't contain the entire PK, which causes this:
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.MappingException: Foreign key (FKD0F44C3AEAE30A85:ACCOUNT_SALES [AccountNumber])) must have same number of columns as the referenced primary key (ACCOUNT_MASTER [MarketId,AccountNumber])
I know this isn't really hibernate's fault, though... I think it's just that the person designing our schema is a nutcase. :)
Is there a way to turn off the attempts at foreign key mapping for these two tables? I tried throwing this at the reveng.xml file, 'cuz I *think* this is what the documentation says I should do:
<table name="ACCOUNT_SALES">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<many-to-one property="accountMaster" exclude="true"/>
</foreign-key>
</table>
<table name="ACCOUNT_MASTER">
<foreign-key constraint-name="FKD0F44C3AEAE30A85:ACCOUNT_SALES">
<set property="accountSaleses" exclude="true"/>
</foreign-key>
</table>
but it doesn't seem to affect the output to either AccountMaster.hbm.xml or AccountSales.hbm.xml ... AccountMaster.hbm.xml still contains:
<set name="accountSaleses" inverse="true">
<key>
<column name="AccountNumber" not-null="true" unique="true" />
</key>
<one-to-many class="AccountSales" />
</set>
and AccountSales.hbm.xml still contains:
<many-to-one name="accountMaster" class="AccountMaster" update="false" insert="false" fetch="select">
<column name="AccountNumber" not-null="true" unique="true" />
</many-to-one>
I'm assuming that I haven't defined the table overrides in my reveng.xml file correctly??
Thanks for all of your help... I know it's dififcult to diagnose other people's stuff. Frankly, I'm amazed that you were able to see my mistake earlier so quickly! :)