Quantcast

Help Mapping One-to-One PK/FK

classic Classic list List threaded Threaded
1 message Options
sia
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Help Mapping One-to-One PK/FK

sia

Hello,

I am having a hard time trying to map a one-to-one using domain mappings. I want to query on the "contact" table and have it eagerly fetch my "user" table, as a contact has a FK in the user table. According to the docs, I would add the BusinessPartnerUser as a variable in the domain class like I did below.

But as soon as I do that, the query it produces tries to query on that column. Here is the query Grails generated. Notice the businessPartnerUser column it is looking for. (BOLD);

How do I get around this. Seems to happen everytime I try and do a one-to-one.

*The bold line is not a column, it is a variable for mapping my user from this contact. But shows up in query. This is problem.
 select
     businesspa0_.CNTCT_ID as CNTCT1_4_,
     businesspa0_.BUSN_ID as BUSN2_4_,
     businesspa0_.business_partner_user_id as business3_4_,
     businesspa0_.CNTCT_ONLY_SW as CNTCT4_4_,
     businesspa0_.CRTE_DT as CRTE5_4_,
     businesspa0_.EMAIL_ADDR_TXT as EMAIL6_4_,
     businesspa0_.FAX_NUM as FAX7_4_,
     businesspa0_.PHN_NUM as PHN8_4_,
     businesspa0_.STAT_CD as STAT9_4_,
     businesspa0_.UPDT_DT as UPDT10_4_
 from
     BUSN_PRTNR_CNTCT businesspa0_
 where
     businesspa0_.BUSN_ID=?



Mapping file producing query.
class BusinessPartnerContact {
  Long id;
  BusinessPartnerUser businessPartnerUser; // needed for one-to-one
  ...
   static mapping = {
    table 'BUSN_PRTNR_CNTCT'
    version false
    id generator: 'sequence', params: [sequence: 'BUSN_PRTNR_CNTCT_SEQ']
    id column: 'CNTCT_ID
   ...
   
  }



thanks.
Scott Purcell
Sr. Engineer, Software
Engineering

MasterCard Worldwide | Global Technology Office
2200 MasterCard Blvd | O'Fallon, MO 63368-7263

tel 636-722-4211
[hidden email]
MasterCard

Please think of the environment before printing this e-mail.



CONFIDENTIALITY NOTICE
This e-mail message and any attachments are only for the use of the intended recipient and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient, any disclosure, distribution or other use of this e-mail message or attachments is prohibited. If you have received this e-mail message in error, please delete and notify the sender immediately. Thank you.
Loading...