<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Locking, Transaction, SFSB, 2 apps
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/braca">Urs Rothenhäusler</a> in <i>Beginner's Corner</i> - <a href="http://community.jboss.org/message/639968#639968">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hello,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I get a row locking error from the database when I try to <strong>read</strong> (and possibly write) a record from a table which has exactly one row. This table holds a value for generating a key. The problem is that this table/entity is accessed by different applications. It's implement like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateful</p><p>@Remote( VZBusinessRemote.class )</p><p>@Local( VZBusinessLocal.class )</p><p>public class VZBean implements VZBusinessLocal, VZBusinessRemote {</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @PersistenceContext(unitName="AUnitEJB") </p><p>&#160;&#160;&#160; private EntityManager em;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; @EJB( name="vzBeanAVPBasis", beanName="AVPBasisBean" )</p><p>&#160;&#160;&#160; private AVPBasisBusinessLocal basisBean;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; private Long key;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Override</p><p>&#160;&#160;&#160; public void unmarshalAVZ( AVZ avz, int startAt, int endat ){</p><p>...domanythings...</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; key = basisBean.findKeyAndSaveKey();</p><p>....domanythings...</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>After invoking the SFSB unmarshalAVZ() and calling basisBean.findKeyAndSaveKey() inside this method other applications cannot read nor write to the table/entity with the key table. Even if I call em.clear() after getting and updating the key table the record is locked for other application, but it should be possible for other apps even to write to the locked record. When the method unmarshalAVZ() is finished, locking isn't a problem anymore, but this method can take a very long time and thus locks the key table.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So - what can I do or what's wrong?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks for an answer</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/639968#639968">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Beginner's Corner at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>