-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: 2.1RC1 breaks some Middlegen generated files w/ foreign keys
PostPosted: Tue Dec 02, 2003 6:35 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
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.

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 6:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I think this one is already fixed in CVS.

Look at http://opensource.atlassian.com/project ... key=HB-512

which actually is bug posted by you - and already fixed at the time you posted here ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 6:44 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Thanks Max,

No, unfortunatly this is a different problem. The other problem referred to not being able to use <meta> tags. I already ran with the cvs change applied, yet I still get this error.

Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 6:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm...ok.

Pleae make a new jira - then i think David will be able to see the problem (or solution even ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 6:57 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Thanks.

The issue is now posted on http://opensource.atlassian.com/project ... key=HB-516


Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 8:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Thanks for the notice of the problem - I will have a look at it tonight (have to do payed work at the moment :-( ). Could you please provide the schema for it so I can double check the original table organisation. I ask as it appears that there are more tables involved than you are showing.

BTW I do find this comment very odd.

Quote:
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.


You did say that the mapping files did work with 2.1Beta6 now since Middlegen r3 was released around the same time as 2.1Beta6 then it matches its goal. Anyway, I try to make Middlegen mostly work with current versions of Hibernate as much as possible. The rc1 release has an issue with CGLIb2 which may or may not be the problem. Anyway, I'll have a look and we will see what I come up with.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 02, 2003 9:49 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
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. I will cross post this on the bug report as well. Please see the bug report if you haven't already where I put some further info.

BTW about the comment regarding migrating from 2.1 Beta 6 to RC1, I did not mean it in a negative way and did not mean to sound odd. You did great work on Hibernate and the plugin for Middlegen. That said, when upgrading to a new version the hope is that code in the previous version would not break and be as backward-compatible as possible. I was simply pointing out that perhaps some more testing to accomplish this would be a good idea.

Thanks for everything,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 12:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Daniel,
Thanks for the extra information. The schema is what I was expecting it to be based on the mappings. It really looks OK visually so I will have to see what happens with the latest Hibernate (and early versions as well).

We do try not to break anything with each release. Even though it is recommended is it still beta software so errors can be present.

We try our best.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 12:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If you can zip up the POJOs and Mappings and send it to me (david@hibernate.org) it would make it a little easier.
Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 1:54 pm 
Regular
Regular

Joined: Tue Nov 11, 2003 7:35 pm
Posts: 63
Hmm, something very interesting happened. I downloaded the nightly snapshot from last night, built it and used the jars in my app. It now works!

My guess is that I was previously running against a possibly incomplete version, where some files were updated and some weren't. This caused the strange behavior.

I thank everyone for their patience and help. I'm glad it turned out to be nothing.

I hope when things quiet down on my project I can contribute back to Hibernate in some way. Good work!


Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 03, 2003 7:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Daniel,
Thanks - My testing last night could not find anything.
Glad you sorted it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.