From: <leg...@at...> - 2003-06-06 03:04:43
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-121 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-121 Summary: Schema export and MySQL AUTO_INCREMENT problem Type: Bug Status: Unassigned Priority: Major Project: Hibernate2 Components: toolset Versions: 2.0rc2 Assignee: Reporter: Richard Mixon Created: Thu, 5 Jun 2003 10:03 PM Updated: Thu, 5 Jun 2003 10:03 PM Environment: Windows XP, J2SDK 1.4.1, Ant 1.5.2, June 5th build of Hibernate Tools from CVS. Description: (Originally posted on forum) By: rnmixon ( Richard Mixon ) Schema export and MySQL AUTO_INCREMENT probl 2003-06-05 17:27 The schema export utility is omitting AUTO_INCREMENT from the actual id property, and erroneously including AUTO_INCREMENT on one part of a two part unique key. I am using "native" id generation. Both parts of the key are many-to-one mappings. I have another table that is mapped the same way and have no problems with it. Is this a bug in schema export? My mapping and the generated DDL are below for the good and bad examples. Thanks much in advance - Richard (sorry for the verbose listing) DDL - START (with wrong AUTO_INCREMENT spec) create table PoAggrMeasurement ( id BIGINT not null, version INTEGER not null, aggregation BIGINT NOT NULL AUTO_INCREMENT, classMeasurement BIGINT not null, status BIGINT, owner BIGINT, createdBy DATETIME not null, createdFromIP DATETIME not null, createdOn BIGINT not null, updatedBy BIGINT not null, updatedFromIP VARCHAR(15) not null, updatedOn VARCHAR(255) not null, primary key (aggregation, classMeasurement), unique (aggregation, classMeasurement) ); DDL - END DDL - START (with wrong AUTO_INCREMENT spec) create table PoEnrollment (correct AUTO_INCREMENT) id BIGINT NOT NULL AUTO_INCREMENT, version INTEGER not null, classOwner BIGINT not null, studentOwner BIGINT not null, status BIGINT, owner BIGINT, createdBy DATETIME not null, createdFromIP DATETIME not null, createdOn BIGINT not null, updatedBy BIGINT not null, updatedFromIP VARCHAR(15) not null, updatedOn VARCHAR(255) not null, primary key (id), unique (classOwner, studentOwner) ); DDL - END MAPPING - START (causes wrong AUTO_INCREMENT spec) <hibernate-mapping> <class name="com.ltoj.persistence.base.PoAggrMeasurement" table="PoAggrMeasurement" dynamic-update="false" > <id name="id" column="id" type="long" unsaved-value="null" > <generator class="native"> </generator> </id> <version name="version" type="int" column="version" /> <many-to-one name="aggregation" class="com.ltoj.persistence.base.PoAggregation" cascade="none" outer-join="auto" update="true" insert="true" > <column name="aggregation" unique-key="userkey" not-null="true" /> </many-to-one> <many-to-one name="classMeasurement" class="com.ltoj.persistence.base.PoClassMeasurement" cascade="none" outer-join="auto" update="true" insert="true" > <column name="classMeasurement" unique-key="userkey" not-null="true" /> </many-to-one> <many-to-one name="status" class="com.ltoj.persistence.base.PoStatus" cascade="none" outer-join="auto" update="true" insert="true" column="status" not-null="false" unique="false" /> <many-to-one name="owner" class="com.ltoj.persistence.base.PoAssociate" cascade="none" outer-join="auto" update="true" insert="true" column="owner" not-null="false" unique="false" /> <property name="auditInfo" type="com.ltoj.persistence.base.PoAuditInfoType" update="true" insert="true" > <column name="createdBy" length="8" not-null="true" /> <column name="createdFromIP" length="15" not-null="true" /> <column name="createdOn" not-null="true" /> <column name="updatedBy" length="8" not-null="true" /> <column name="updatedFromIP" length="15" not-null="true" /> <column name="updatedOn" not-null="true" /> </property> <!-- To add non XDoclet property mappings, create a file named hibernate-properties-PoAggrMeasurement.xml containing the additional properties and place it in your merge dir. --> </class> <query name="PoAggrMeasurement.all"><![CDATA[ from am in class com.ltoj.persistence.base.PoAggMeasurement ]]></query> </hibernate-mapping> MAPPING - END MAPPING - START (correct AUTO_INCREMENT spec) <hibernate-mapping> <class name="com.ltoj.persistence.base.PoEnrollment" table="PoEnrollment" dynamic-update="false" > <id name="id" column="id" type="long" unsaved-value="null" > <generator class="native"> </generator> </id> <version name="version" type="int" column="version" /> <many-to-one name="classOwner" class="com.ltoj.persistence.base.PoClass" cascade="none" outer-join="auto" update="true" insert="true" > <column name="classOwner" unique-key="userkey" not-null="true" /> </many-to-one> <many-to-one name="studentOwner" class="com.ltoj.persistence.base.PoStudent" cascade="none" outer-join="auto" update="true" insert="true" > <column name="studentOwner" unique-key="userkey" not-null="true" /> </many-to-one> <many-to-one name="status" class="com.ltoj.persistence.base.PoStatus" cascade="none" outer-join="auto" update="true" insert="true" column="status" not-null="false" unique="false" /> <many-to-one name="owner" class="com.ltoj.persistence.base.PoAssociate" cascade="none" outer-join="auto" update="true" insert="true" column="owner" not-null="false" unique="false" /> <property name="auditInfo" type="com.ltoj.persistence.base.PoAuditInfoType" update="true" insert="true" > <column name="createdBy" length="8" not-null="true" /> <column name="createdFromIP" length="15" not-null="true" /> <column name="createdOn" not-null="true" /> <column name="updatedBy" length="8" not-null="true" /> <column name="updatedFromIP" length="15" not-null="true" /> <column name="updatedOn" not-null="true" /> </property> <!-- To add non XDoclet property mappings, create a file named hibernate-properties-PoEnrollment.xml containing the additional properties and place it in your merge dir. --> </class> </hibernate-mapping> MAPPING - END --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |