0 Replies Latest reply: Apr 12, 2012 4:37 AM by Martin Isheim RSS

EJB2.1 CMR relation not visible in new created entity bean

Martin Isheim Newbie

Hi all,

 

we are migrating from JBoss-4.2.2 to AS 7.1.1 and found a lot of help in the forum entries, thanks.

But one problem blocks us, which didn't occur in AS 4.2.2:

 

We have a number of ejb2.1 entity beans with CMR relations, e.g. entity "JCLevelB" as relation owner has in its bean a CMR field "jCSubB1s",

to relate dependent entites "JCSubB1":

 

public abstract class JCLevelBBean implements EntityBean

[...]

    public abstract Set<JCSubB1> getJCSubB1s();

    public abstract void setJCSubB1s(Set<JCSubB1> jCSubB1s);

 

Creating a new relation owner with a dependent entity works fine:

EJBLocalObject gLocal = getLocalHome().create(data);

 

But the dependent entity is not found within further bean accesses, using "gLocal" within the same transaction:

JCLevelBBean.getJCSubB1s() returns an empty collection (wrong).

 

After the tranaction is committed, in a new transaction the dependent entity is found in the relation owner (and in the database),

JCLevelBBean.getJCSubB1s() returns the filled collection (correct).

The problem does not occur, if the relation owner was created before in a separate transaction

and in the current transaction only a new relation is established.

The problem does no depent on the dependent entity, if it was created before or is created together with the relation owner.

 

Is there some configuration needed for CMR to include such updates in the current transaction?

 

Here the section of the ejb-jar.xml with the relation:

        <ejb-relation>

            <ejb-relation-name>JCLEVELB_JCSUBB1S</ejb-relation-name>

            <ejb-relationship-role>

                <ejb-relationship-role-name>JCLevelB Role</ejb-relationship-role-name>

                <multiplicity>One</multiplicity>

                <relationship-role-source>

                    <ejb-name>JCLevelBBean</ejb-name>

                </relationship-role-source>

                <cmr-field>

                    <cmr-field-name>jCSubB1s</cmr-field-name>

                    <cmr-field-type>java.util.Set</cmr-field-type>

                </cmr-field>

            </ejb-relationship-role>

            <ejb-relationship-role>

                <ejb-relationship-role-name>JCSubB1s Role</ejb-relationship-role-name>

                <multiplicity>Many</multiplicity>

                <cascade-delete/>

                <relationship-role-source>

                    <ejb-name>JCSubB1Bean</ejb-name>

                </relationship-role-source>

            </ejb-relationship-role>

        </ejb-relation>

 

Thanks for any hint,

Martin