I have a MySQL database I went thru middlegen to create mappings and then to the Hibernate CodeGenerator for the classes.
Figured this would be fast, if not pretty.
Well, it appears I'm getting Key fields that are being ignored in creating the XML files. DDL and XML example follow. Ideas?
-Joe
---------------------------------------------
DROP DATABASE IF EXISTS bb;
CREATE DATABASE bb;
CREATE TABLE bb.LanguageCode
(LanguageCode CHAR(2) NOT NULL,
PRIMARY KEY(LanguageCode)) TYPE=INNODB;
CREATE TABLE bb.LanguageProficiencyCode
(ProficiencyCode SMALLINT NOT NULL,
PRIMARY KEY(ProficiencyCode)) TYPE=INNODB;
CREATE TABLE bb.HairColorCode
(HairColorCode VARCHAR(10) NOT NULL,
PRIMARY KEY(HairColorCode)) TYPE=INNODB;
CREATE TABLE bb.EyeColorCode
(EyeColorCode VARCHAR(10) NOT NULL,
PRIMARY KEY(EyeColorCode)) TYPE=INNODB;
CREATE TABLE bb.EyeColorDesc
(EyeColorCode CHAR(10) NOT NULL,
INDEX eye_ind(EyeColorCode),
FOREIGN KEY (EyeColorCode) REFERENCES EyeColorCode(EyeColorCode) ON UPDATE CASCADE,
LanguageCode CHAR(2) NOT NULL,
INDEX lang_ind(LanguageCode),
FOREIGN KEY (LanguageCode) REFERENCES LanguageCode(LanguageCode) ON UPDATE CASCADE,
EyeColorDesc VARCHAR(20) NOT NULL,
PRIMARY KEY(EyeColorCode,LanguageCode)) TYPE=INNODB;
<?xml version="1.0" encoding="UTF-8"?>
<import class="cdata" />
<hibernate-mapping>
<!--
Created by Middlegen Hibernate plugin
http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->
<class
name="bb.hibernate.Eyecolordesc"
table="eyecolordesc"
>
<property
name="eyeColorDesc"
type="java.lang.String"
column="EyeColorDesc"
not-null="true"
length="20"
/>
<!-- associations -->
<!-- bi-directional many-to-one association to Languagecode -->
<many-to-one
name="languagecode"
class="bb.hibernate.Languagecode"
not-null="true"
>
<column name="LanguageCode" />
</many-to-one>
<!-- bi-directional many-to-one association to Eyecolorcode -->
<many-to-one
name="eyecolorcode"
class="bb.hibernate.Eyecolorcode"
not-null="true"
>
<column name="EyeColorCode" />
</many-to-one>
</class>
</hibernate-mapping>