• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

What if the PK is also a FK ???

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should the procedure (in ejbCreate() and ejbPostCreate() ) be if our (a concat one) PK is also a FK (cmr field)???

Suppose table COmpanyEmail:
companyID -> PK and FK
email -> PK

We cannot set both at ejbCreate() because companyID is a CMR field, but, on the other hand we must set both at ejbCreate() because the PKs must be set in ejbCreate().
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leandro

What kind of relation is the table (companyId,email)? If you can let us know your database model a little bit it would be more helpful.

Because if it sounds confusing, it may be confusing by design itself.

Thanks
Maulin
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
also I think you are trying to model "Relation table" using Entity bean hence facing the problem (just a guess from your earlier post...)

Regards
Maulin
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maulin, this is not a relation table (this is a 1..N relation)
I got a table COMPANY with fields:
- companyID (PK)
- companyName
- companyType
- etc...

Then, i got a table COMPANY_EMAIL with fields.
- email (PK)
- companyID(PK and also a FK)


Note that i'm not really interested if this is the best database shema model, but on how to specifically model this situation with Entity CMPs.

Ye, i know i could change the database schema in this case (making only the email a PK), but i'm sure that situations like this may happen again and i might not be apple to change the database schema. That's way i'm looking for a solution for that.

If you need more information to help me, let me know.
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay I see how it is now...

Well, its not a problem. It happens as CompanyEmail is Weak entity. I have similar things dealt with as I had Rule and Condition objects where Condition was WeakEntity and ConditionKey must have RuleID in there..

I will let you know tomorrow what did I do there..


Thanks
Maulin
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you can use CMR field option in the CMP for this Entity Bean Model.
 
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic