1 Reply Latest reply on Jul 9, 2002 2:11 PM by Dain Sundstrom

    Transaction-Types, the AutoNumberBean and Relationships

    Hans Newbie

      Hi,

      I use JBoss 3.0 with MySql and Hypersonic and I use the AutoNumber-Bean for generating Ids.

      I have two entity-beans A and B where B belongs to A. (unidirectional 1-1).

      If I create the ID's manually everything works fine and the foreign key for B is inserted into A.

      If I set the transaction-type of the AutoNumberBeans to Required and if I use AutoNumberFactory.getNextInteger(..) to generate the ids in the respective create-methods no value for the foreign-key is inserted into A-table. B is inserted with the generated PrimaryKey, the same is true for A, but the foreign-key is missing.
      Everything works fine again if I set the transaction-type of the AutoNumberBean to RequiresNew.

      So it works and the transaction-type = RequiresNew is anyway the best choice I think. But why doesn't it work otherwise ? I posted this message to learn something and it might be of some help for others.