• 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

CMR and composite foriegn key

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have a table say A for which two columns constitute primary key col-a and say col-b.
A has one to many relationship to another table X. Both the above said colulmns are there in table X and have foreign key constraint to table A.
We are getting exceptions when we try to set the collection of entity X to entity A, since the foreign keys are not automatically updated.
Basic quetion is does CMR works for composite foreign keys??
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes
 
Monmohan Singh
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When we try to call addAll() on the collection , the container throws a null pointer exception.
On a side note for a composite primary key, can u tell me what is a good hashcode implementation? coz I think that also may be the problem
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://developer.java.sun.com/developer/Books/effectivejava/Chapter3.pdf
 
Monmohan Singh
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the error that we are getting when adding an enity threshold to another entity Adjustments
Adjustment table has two columns as the primary key(the class AdjustmentPK) and hence these are also foreign keys in threshold. It throws an exception whenever we are trying to add a threshold refernce to adjustment..
Most of the code is generated by the ejbgen tool

java.lang.NullPointerException
at com.circuitcity.vma.ejb.pa.local.AdjustmentsPK.hashCode(AdjustmentsPK
.java:26)
at com.circuitcity.vma.ejb.pa.local.AdjustmentsPK.equals(AdjustmentsPK.j
ava:43)
at com.circuitcity.vma.ejb.pa.local.PAAdjustmentsEntityBean_5r9txz__WebL
ogic_CMP_RDBMS_threshHolds_Set.add(PAAdjustmentsEntityBean_5r9txz__WebLogic_CMP_
RDBMS_threshHolds_Set.java:282)
at com.circuitcity.vma.ejb.pa.helper.PAAdjustmentEntityHelper.updateThre
shHold(PAAdjustmentEntityHelper.java:115)
at com.circuitcity.vma.ejb.pa.helper.PAAdjustmentEntityHelper.create(PAA
djustmentEntityHelper.java:86)
at com.circuitcity.vma.ejb.pa.helper.PAAdjustmentEntityHelper.create(PAA
djustmentEntityHelper.java:57)
at com.circuitcity.vma.ejb.pa.helper.PAEntityHelper.updateAdjustments(PA
EntityHelper.java:121)
at com.circuitcity.vma.ejb.pa.local.PASessionFacade.updateAdjustments(PA
SessionFacade.java:97)
at com.circuitcity.vma.ejb.pa.local.PASessionFacade_8sw7cg_EOImpl.update
Adjustments(PASessionFacade_8sw7cg_EOImpl.java:154)
at com.circuitcity.vma.ejb.pa.local.PASessionFacade_8sw7cg_EOImpl_WLSkel
.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
eManager.java:785)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
error...null
 
Monmohan Singh
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, we found the error .. the ejbgen tool has generated the primary key class in which the hashcode method used to give null pointer exception since the objct on which the method is called is null before the container sets the relationship fields!!
 
If we don't do the shopping, we won't have anything for dinner. And I've invited 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