From: <leg...@at...> - 2003-12-03 01:49:41
|
The following comment has been added to this issue: Author: Daniel Rosenbaum Created: Tue, 2 Dec 2003 7:49 PM Body: Another followup: The schema. Unfortunatly I am now on my other computer and do not have access to the schema. I partially constructed it from memory though, I can provide a more complete one if necessary tomorrow morning US Eastern time. I hope I have this accurate as well: create table QWB_EXTRCT_VW { EXTRCT_VW_NUM NUMBER not null, other columns......, primary key(EXTRCT_VW_NUM) }; create table QWB_EXTRCT_VW_CLMN { EXTRCT_VW_NUM NUMBER not null, FLDR_CLMN_NUM NUMBER not null, other columns....., primary key (EXTRCT_VW_NUM), primary key (FLDR_CLMN_NUM), CONSTRAINT SYS_1 FOREIGN KEY (EXTRCT_VW_NUM) REFERENCES QWB_EXTRCT_VW(EXTRCT_VW_NUM), CONSTRAINT SYS_2 FOREIGN KEY (FLDR_CLMN_NUM) REFERENCES QWB_FLDR_CLMN(FLDR_CLMN_NUM), ); create table QWB_FLDR { FLDR_NUM NUMBER not null, other columns......, primary key (FLDR_NUM) }; create table QWB_FLDR_CLMN { FLDR_CLMN_NUM NUMBER not null, FLDR_NUM not null, primary key (FLDR_CLMN_NUM) CONSTRAINT SYS_3 FOREIGN KEY (FLDR_NUM) REFERENCES QWB_FLDR(FLDR_NUM), }; Note that table QWB_FLDR_CLMN has only one primary key and one separrte foreign key while QWB_EXTRCT_VW_CLMN has two primary keys which themselves are foreign keys as well. I hope this helps. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-516 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-516 Summary: 2.1RC1 breaks some Middlegen generated files w/ foreign keys Type: Bug Status: Unassigned Priority: Major Project: Hibernate2 Components: toolset Versions: 2.1 rc1 Assignee: Reporter: Daniel Rosenbaum Created: Tue, 2 Dec 2003 4:56 PM Updated: Tue, 2 Dec 2003 7:49 PM Environment: 2.1RC1 with Oracle Description: I have two tables, QWB_EXTRCT_VW_CLMN and QWB_FLDR_CLMN. QWB_EXTRCT_VW_CLMN has a composite primary key with columns EXTRCT_VW_NUM and FLDR_CLMN_NUM, FLDR_CLMN_NUM being a foreign key to the (single) primary key of the QWB_FLDR_CLMN table. Middlegen generates the following mapping for QwbFldrClmn: <composite-id name="comp_id" class="testQwb.hibernate.persistent.QwbExtrctVwClmnPK"> <meta attribute="field-description"> @hibernate.id generator-class="assigned" </meta> <!-- uni-directional one-to-one association to QwbFldrClmn --> <key-many-to-one name="qwbFldrClmn" class="testQwb.hibernate.persistent.QwbFldrClmn" > <column name="FLDR_CLMN_NUM" /> </key-many-to-one> <!-- bi-directional many-to-one association to QwbExtrctVw --> <key-many-to-one name="qwbExtrctVw" class="testQwb.hibernate.persistent.QwbExtrctVw" > <column name="EXTRCT_VW_NUM" /> </key-many-to-one> </composite-id> However when run the following exception is thrown: net.sf.hibernate.MappingException: Foreign key (QWB_EXTRCT_VW_CLMN [FLDR_CLMN_NUM])) must have same number of columns as the reference primary key (QWB_FLDR_CLMN [FLDR_NUM,FLDR_CLMN_NUM]) at net.sf.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:60) at net.sf.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:625) at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:719) at org.ifmc.qw.hibernate.HibernateSession.init(HibernateSession.java:44) at testQwb.hibernate.TestHibernate3.main(TestHibernate3.java:22) Note that this xml works with the 2.1 beta 6, but not with RC1. Is Middlegen not putting something in? BTW in general I am having a heck of a time migrating from 2.1 Beta 6 to RC1 using Middlegen created XML files. Seems to me to be a good idea to do more testing with Middlegen and Hibernate to make sure the generated files work. Or else modify Hibernate or Middlegen so they would cooperate better. Also please note that this is NOT the same problem as with HB-512, I am already using the patched code but yet I now have this new error. Thanks, Daniel --------------------------------------------------------------------- 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/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |