AW: foreign-key generation maps NumberKey to int, and code fails to compile
Hi! I'm not sure if I understand you problem. But does it make sense to declare a foreign key for primary key in the same table? Normally you declare the foreign key in COUPON and make a reference to MEMBER. Maybe Torque doesn't like this double key-definition in MEMBER. But I'm not sure bye Thoralf -Ursprüngliche Nachricht- Von: brycenesbitt [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 14. August 2007 08:59 An: torque-user@db.apache.org Betreff: foreign-key generation maps NumberKey to int, and code fails to compile I'm adding a table to an older Torque based application: table name=CCS_MEMBER column default=0 name=MEMBER_ID primaryKey=true required=true type=INTEGER/ column default= name=FIRST_NAME size=127 type=VARCHAR/ column default= name=LAST_NAME size=127 type=VARCHAR/ foreign-key foreignTable=CCS_COUPON reference local=MEMBER_ID foreign=MEMBER_ID/ /foreign-key /table table name=CCS_COUPON column name=COUPON_ID type=INTEGER primaryKey=true required=true autoIncrement=true / column name=MEMBER_ID type=INTEGER required=true / column name=EXPIRES type=DATE/ /table But when Torque generates the classes there is a type mismatch. The coupon gets an integer for MEMBER_ID, but the member generates a NumberKey. Is there a way to resolve this? It seems OK if the primary key maps to another primary key (both are NumberKeys). Is there a way to force Torque to use a NumberKey for a non-primary key? Or to force Torque to use an integer for a primary key (more risky, since that's a change to existing code)? If it matters, this is Torque 3.0-b4 (yes, beta 4). -- View this message in context: http://www.nabble.com/foreign-key-generation-maps-NumberKey-to -int%2C-and-code-fails-to-compile-tf4265600.html#a12139688 Sent from the Apache DB - Torque Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: AW: foreign-key generation maps NumberKey to int, and code fails to compile
Ah, okay, a coupon has only one member. Is it possible to have a member that has multiple coupons? Or is it a 1:1 relation? If so, you could make a circle reference from member to coupon. If it is 1:n relation (I think so), then you should add a third table COUPON_MEMBER_RELATION with member_id,coupon_id as foreign keys and unique(member_id,coupon_id) and maybe unique(coupon_id). bye Thoralf -Ursprüngliche Nachricht- Von: brycenesbitt [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 14. August 2007 09:39 An: torque-user@db.apache.org Betreff: Re: AW: foreign-key generation maps NumberKey to int, and code fails to compile Hmm, ok. But if I flip it around like that, I don't get a BaseCcsMemberPeer.doSelectJoinCcsCoupon(). table name=CCS_MEMBER column default=0 name=MEMBER_ID primaryKey=true required=true type=INTEGER/ column default= name=FIRST_NAME size=127 type=VARCHAR/ column default= name=LAST_NAME size=127 type=VARCHAR/ /table table name=CCS_COUPON column name=COUPON_ID type=INTEGER primaryKey=true required=true autoIncrement=true / column name=MEMBER_ID type=INTEGER required=true / column name=EXPIRES type=DATE/ foreign-key foreignTable=CCS_MEMBER onUpdate=none onDelete=none name=FK_COUPON reference local=MEMBER_ID foreign=MEMBER_ID/ /foreign-key /table How can I get a BaseCcsMemberPeer.doSelectJoinCcsCoupon(), which will do essentially: SELECT * from CCS_MEMBER JOIN CCS_COUPON USING (MEMBER_ID); All I get is BaseCcsCouponPeer.doSelectJoinCcsMember() method, which selects a collection of CcsCoupon objects pre-filled with their CcsMember objects. But this is useless, since there can be only one member per coupon! I want a member object, with a list of (zero or more) coupons. Thoralf Rickert wrote: I'm not sure if I understand you problem. But does it make sense to declare a foreign key for primary key in the same table? Normally you declare the foreign key in COUPON and make a reference to MEMBER. Maybe Torque doesn't like this double key-definition in MEMBER. But I'm not sure bye Thoralf -- View this message in context: http://www.nabble.com/foreign-key-generation-maps-NumberKey-to -int%2C-and-code-fails-to-compile-tf4265600.html#a12140061 Sent from the Apache DB - Torque Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: AW: AW: foreign-key generation maps NumberKey to int, and code fails to compile
In BaseCcsCouponPeer should be a doSelectJoinCcsMember() method. The other way around is not implemented. So you need to program it yourself, I think. The member doesn't know about the coupons, so it isn't possible to build automatically a doSelectJoinCcsCoupons. Additionally in MemberPeer you try to SELECT a member and add multiple coupons to it. This isn't easy with a single SELECT. (because the member has multiple coupons and you'll get multiple rows for one member). You could make two selects. First get the CcsMember and then call CcsMember.getCoupons(). This method is implemented in BaseCcsMember. -Ursprüngliche Nachricht- Von: brycenesbitt [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 14. August 2007 10:14 An: torque-user@db.apache.org Betreff: Re: AW: AW: foreign-key generation maps NumberKey to int, and code fails to compile Each coupon is owned by one member. A member may have any number of coupons. SQL has no trouble setting up such a relationship without a third table. Do I need the third table to satisfy Torque? Thoralf Rickert wrote: Ah, okay, a coupon has only one member. Is it possible to have a member that has multiple coupons? Or is it a 1:1 relation? If so, you could make a circle reference from member to coupon. If it is 1:n relation (I think so), then you should add a third table COUPON_MEMBER_RELATION with member_id,coupon_id as foreign keys and unique(member_id,coupon_id) and maybe unique(coupon_id). bye Thoralf -- View this message in context: http://www.nabble.com/foreign-key-generation-maps-NumberKey-to -int%2C-and-code-fails-to-compile-tf4265600.html#a12140496 Sent from the Apache DB - Torque Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]