• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

one-to-one relationship

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to create a one-to-one relationship for this two table,

Items
- ItemId (auto increment)
- SoftwareId
- PackageId

Software
- SoftwareId
- SoftwareName

this is my relationship in jbosscmp-jdbc.xml


<ejb-relation>
<ejb-relation-name>PackageItems-Software</ejb-relation-name>
<foreign-key-mapping/>

<ejb-relationship-role>
<ejb-relationship-role-name>packageitems-has-software</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>softwareId</field-name>
<column-name>SOFTWAREID</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>

<ejb-relationship-role>
<ejb-relationship-role-name>software-belongs-to-packageitems</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>



I keep getting error "org.jboss.deployment.DeploymentException: Role 'packageitems-has-software' on Entity Bean 'SoftwarePackageItemsEJB' : CMP field for key not found: field name='softwareId'"

Is it true that only can define primary keys in <key-field>? if yes, then how should i join this two table?

pls advise.Thanks.
 
Author
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try putting the key-field on the software-belongs-to-packageitems side since the id belongs to that side of the relationship.

You should definitely check out chapter 7 of the book to learn how to configure persistence. We have a very similar example and offer this as simple explanation:

[code]
In JBoss, key fields for relationships are always defined on the
source side of the relationship, regardless of whether they are mapped as
foreign keys in another entity table or in a middle table. Although it may
seem slightly odd in this particular case, JBoss is very consistent.


It's slightly out of context, but I think it should make sense.
 
I guess everyone has an angle. Fine, what do you want? Just know that you cannot have this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic