Transaction & Relationships problem


EJB programming & troubleshooting: Transaction & Relationships problem

  1. Transaction & Relationships problem (2 messages)


    I'm using Weblogic 6.1 with EJB 2.0
    I've an account bean that has a relationship one/one with a person bean, I create the person in the postcreate method of the account bean, as it is given in example in the "bands" example.
    the problem is that when the account creation fails, my person is created in the database and not rolled back
    does some one have an idea about this problem, is that a bug in weblogic or do I something wrong.
    Thanks for your help.

  2. hi there is absolutely no problem with your weblogic in this case at all.

    As you are creating person in the postcreate method, somehow you have to mention how to handle the person bean in case the account fails. You can do this, explicitly in the postcreate method.

    As you said, person is created even if account is failing. And your person is in postCreate method. This means.. your create is fine.. as it is reaching to the postCreate method (because person is getting created).. now there are two doubts i have:
    1. Are you calling the postCreate explicitly ? if yes, where?
    2. Where exactly the account is failing?

    this will give u a wage idea, i mean you will be able to find out .. about the failure..

    more later..
  3. Hi Shiv,
    first off all thanks for your answer.

    To answer your questions, No I don't call the postCreate method explicitly.

    The account creation failed because I tried to insert a null value into a non nullable column of my database.
    I know this should'nt happen in "real life". But I was affraid that my problem could also happen in other failures.

    Another question, what's the best way for you to tell the postCreate that my create failed ?