- This topic has 3 replies, 3 voices, and was last updated 20 years, 1 month ago by paulbhart.
-
AuthorPosts
-
paulbhartMemberI have a DB table created in MySQL using the following SQL
create table apackage
(
apackageID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY(apackageID),
userID_fk integer,
FOREIGN KEY (userID_fk) REFERENCES user(userID),
status integer ZEROFILL,
description varchar(50),
notefield mediumtext,
basepackageID_fk integer,
addonpackageID_fk integer,
index userID_index (userid_fk),
index bpID_index (basepackageID_fk),
index aopID_index (addonpackageID_fk)
) ENGINE=INNODB;When I use the create Hibernate Mapping function I get a duplicate
entry for the addonpackageID_fk (called addonpackage1, why the 1
I also don’t know) in both the hbm.xml and .java file.See below, Any ideas?
— .hbm.xml file–<?xml version=”1.0″?>
<!DOCTYPE hibernate-mapping PUBLIC
“-//Hibernate/Hibernate Mapping DTD 2.0//EN”
“http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd” ><!– DO NOT EDIT: This is a generated file that is synchronized –>
<!– by MyEclipse Hibernate tool integration. –>
<!– Created Thu Oct 28 13:40:55 EDT 2004 –>
<hibernate-mapping package=”miango.hibernate”><class name=”Apackage” table=”apackage”>
<id name=”apackageid” column=”apackageID” type=”java.lang.Integer”>
<generator class=”identity”/>
</id><property name=”status” column=”status” type=”java.lang.String” />
<property name=”description” column=”description” type=”java.lang.String” />
<property name=”notefield” column=”notefield” type=”java.lang.String” /><many-to-one name=”addonpackage1″ column=”addonpackageID_fk” class=”Addonpackage” />
<many-to-one name=”user” column=”userID_fk” class=”User” /><many-to-one name=”basepackage” column=”basepackageID_fk” class=”Basepackage” />
<many-to-one name=”addonpackage1″ column=”addonpackageID_fk” class=”Addonpackage” />
</class>
</hibernate-mapping>— Partial listing of AbstractAPackage —
/*
* WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized
* by MyEclipse Hibernate tool integration.
*
* Created Thu Oct 28 13:40:55 EDT 2004 by MyEclipse Hibernate Tool.
*/
package miango.hibernate;import java.io.Serializable;
/**
* A class that represents a row in the apackage table.
* You can customize the behavior of this class by editing the class, {@link Apackage()}.
* WARNING: DO NOT EDIT THIS FILE. This is a generated file that is synchronized * by MyEclipse Hibernate tool integration.
*/
public abstract class AbstractApackage
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;/** The composite primary key value. */
private java.lang.Integer apackageid;/** The value of the addonpackage1 association. */
private Addonpackage addonpackage1;
/** The value of the user association. */
private User user;/** The value of the basepackage association. */
private Basepackage basepackage;/** The value of the addonpackage1 association. */
private Addonpackage addonpackage1;/** The value of the simple status property. */
private java.lang.String status;
Riyad KallaMemberI sent this to our Hib dev but he is up to his neck in work right now, stay tuned I’m sure he will reply soon.
support-jeffMemberPaul –
I need more info to be able to help you. SPecifically, what version of mysql are you using and what JDBC connector (and version). Also, the many-to-one mappings are only created when there is a foreign key mapping present – I only see the definition for userID_fk. Where is the FK DDL for the other mappings (including addonpackage)?
jeff
paulbhartMemberOk MySQL version is 5.0.1-alpha-nt-max
JDBC driver is jdbc2_0-stdext.jarhere is the file I use to create the DB. My DB design is rustry so wouldn’t
doubt if I have an issue in my design causing issues with the hibernate module.Create table user
(
email varchar(50) NOT NULL UNIQUE,
userID integer AUTO_INCREMENT,
PRIMARY KEY (userid),
index userID_index (userID),
password char(10) NOT NULL,
firstname varchar(50) NOT NULL,
lastname varchar(50) NOT NULL,
middleinitial char(1),
streetaddress1 varchar(50),
streetaddress2 varchar(50),
city varchar(50),
state varchar(50),
zipcode char(20),
primaryphonenumber char(20),
secondaryphonenumber char(20)
) ENGINE=INNODB;create table roll
(
directory varchar(150) NOT NULL,
rollID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (rollID),
userid_fk int,
FOREIGN KEY (userID_fk) REFERENCES user(userID),
INDEX userID_index (userID_fk),
INDEX rollID_index (rollID)
)ENGINE=INNODB;create table digitalfile
(
digitalfileID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY(digitalfileID),
displayname varchar(50) NOT NULL,
localfilename varchar(50) NOT NULL,
rollID_fk integer,
FOREIGN KEY (rollID_fk) REFERENCES roll(rollID),
INDEX rollID_index (rollID_fk),
INDEX dititalfileID_index (digitalfileID)
) ENGINE=INNODB;— Create package but without FK to basepackage and addonpackage, do this later
create table apackage
(
apackageID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY(apackageID),
userID_fk integer,
FOREIGN KEY (userID_fk) REFERENCES user(userID),
status integer ZEROFILL,
description varchar(50),
notefield mediumtext,
basepackageID_fk integer,
addonpackageID_fk integer,
index userID_index (userid_fk),
index bpID_index (basepackageID_fk),
index aopID_index (addonpackageID_fk)
) ENGINE=INNODB;create table basepackage
(
basepackageID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (basepackageID),
description varchar(150),
cost real,
index bpid_index (basepackageID))ENGINE=INNODB;
— OK, now that basepackage created add a fk in package
ALTER TABLE apackage ADD FOREIGN KEY (basepackageID_fk) REFERENCES basepackage(basepackageID);create table basesizesavailable
(
basesizesavailableID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (basesizesavailableID),
basepackageID_fk integer,
FOREIGN KEY (basepackageID_fk) REFERENCES basepackage(basepackageID),
quantity integer NOT NULL,
width real,
height real,
index bpid_index (basepackageID_fk)
)ENGINE=INNODB;create table addonpackage
(
addonpackageID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (addonpackageID),
description varchar(150),
cost real,
index addonpackageID_index (addonpackageID)
)ENGINE=INNODB;— OK, now that addonpackage creaed add a fk in package
ALTER TABLE apackage ADD FOREIGN KEY (addonpackageID_fk) REFERENCES addonpackage(addonpackageID);create table addonsizesavailable
(
addonsizesavailableID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (addonsizesavailableID),
addonpackageID_fk integer,
FOREIGN KEY (addonpackageID_fk) REFERENCES addonpackage(addonpackageID),
quantityper integer,
height real,
width real,
cost real,
INDEX addonpackageID_index (addonpackageID_fk)) ENGINE=INNODB;
create table printedphoto
(
printedphotoID integer NOT NULL AUTO_INCREMENT,
PRIMARY KEY (printedphotoID),
apackageID_fk integer,
FOREIGN KEY (apackageID_fk) REFERENCES apackage(apackageID),
userID_fk integer,
FOREIGN KEY (userID_fk) REFERENCES apackage(userID_fk),
digitalfileid_fk integer,
FOREIGN KEY (digitalfileID_fk) REFERENCES digitalfile(digitalfileID),
height real,
width real,
INDEX printedphotoID_index(printedphotoID),
INDEX apackageID_index(apackageID_fk),
INDEX userID_index(userID_fk),
INDEX digitalfileID_index(digitalfileID_fk)
)ENGINE=INNODB; -
AuthorPosts