Alex, 
 I've done some more investigation on this and the problem appears to be
somewhere (haven't tracked it down) in the synchronization of the entity
bean to the database/caching logic. The sequence of events in my unit test
is:

- Create Package
- Create PackageUser (Sender)
- PostCreate links sender with package
- Call a finder to get the recipients "role".
- Create PackageUser (Recipient)
- PostCreate links recipient with package
....
- Call getUserPackage (CMR relationship) on Recipient to get the package -
this fails.

The CMR relationship is:

public abstract class PackageUserEJB extends AbstractEntityBean {
...
    /**
     *
     * Returns the Package for the package user.
     *
     * @return Package for the package user
     *
     * @ejb:interface-method
     *
     * @ejb:relation
     *    name="Package-PackageUser"
     *    role-name="N-PackageUser-1-Package"
     *    cascade-delete="yes"
     * @jboss:relation
     *    fk-column="packageId"
     *    related-pk-field="id"
     */
    public abstract PackageLocal getUserPackage();
...
}

public abstract class PackageEJB extends AbstractEntityBean {
...
    /**
     * Gets users of this Package
     *
     * @return PackageUsers of this Package
     *
     * @ejb:relation
     *    name="Package-PackageUser"
     *    role-name="1-Package-N-PackageUser"
     * @ejb:interface-method
     */
    public abstract Collection /* PackageUserLocal */ getPackageUsers();
...
}


The reason I suspect caching of the entity bean  is because if I add a
finder call after the create of the recipient bean - which forces the
synchronization of the bean to the database - then everything works fine.
Which most likely explains why the UI works fine (it has a lot of finder
calls).
 
 Do you know of any problems in this area? Any pointers on where I should be
looking to narrow this down? I'm going to spend some more time investigating
and if I can I'll try to put to get a reproducible test case (don't hold
your breath). 

 A couple of points about the set up (not sure if they're relevant):

- Using 3.2.2RC1 (code works fine on 3.2.0)
- The unit test (using cactus) is single threaded
- The unit test is a single transaction.
- We're using "Instance Per Transaction CMP 2.x EntityBean"
- Using database create primary keys (a la JDBCSQLServerCreateCommand)

thanks,
gavin



-----Original Message-----

From: Alexey Loubyansky <[EMAIL PROTECTED]> 
 Re: CMR relationship not being created........sometimes   
2003-06-28 01:50  
 Hello Gavin,
 
 please, provide more info (code snippets) on how the code from UI
 differs from testcases. I'll look at it.
 
 Thanks,
 alex
 
 Saturday, June 28, 2003, 6:57:23 AM, Gavin Matthews wrote:
 
 GM> All, 
 GM>  This is a long shot and pretty sparse on detail but just incase
someones
 GM> come across this before....
 
 GM>  I'm upgrading from 3.2.0 to 3.2.2RC1 but I'm now seeing a strange CMR
 GM> problem where by the foreign-key is not getting populated (sometimes).
A
 GM> quick description of the senario, this is a mail app with recipients,
 GM> senders and packages. Recipients and senders are represented by
PackageUser
 GM> beans and there's a CMR relationship with the Package bean (many to 1).
This
 GM> is where things get strange - through the UI everything works
absolutely
 GM> perfectly. However in our unit tests (cactus) I'm seeing a strange
problem.
 
 GM>  When I create a PackageUser it is associated with a Package (in
 GM> ejbPostCreate). What I'm seeing is that for the first PackageUser (the
 GM> sender) the association is working fine but the second (the recipient)
is
 GM> not getting populated (i.e. the foreign key stays as NULL). Which means
that
 GM> later on when I look at the package it has no recipients and causes a
 GM> failure.
 
 GM>  Just to re-iterate, everything works fine through our UI and in 3.2.0
there
 GM> was no such problem. This makes me think there may be some issue with
the
 GM> behaviour of CMR depending on the transactionality of the calls. Where
does
 GM> JBoss handle the flushing of the data - are there any known issues in
this
 GM> area (I had a look at the list and the bugs but nothing struck me as
 GM> similar). I've spent the day investigating and haven't gotten anywhere,
any
 GM> suggestions would be appreciated.
 
 GM>  I've attached the an excerpt from the server log. The interesting
lines
 GM> are:
 
 GM> 2003-06-27 20:46:49,468 INFO  ...
*****************************************
 GM> 2003-06-27 20:46:49,468 INFO  ... CreateSender: PackageId=14
 GM> 2003-06-27 20:46:49,468 INFO  ...
*****************************************
 GM> ...
 GM> 2003-06-27 20:46:49,484 DEBUG
 GM>
[org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSQLServerCreateCommand.PackageUse
 GM> r] Executing SQL: INSERT INTO MessengerPackageUser (pickupKey,
category,
 GM> expireTime, isSaved, recallTime, lifeCycleState, lifeCycleStateTime,
 GM> pickupTime, pickupState, pickupStateTime, streamPickupStates, address,
 GM> fullName, displayName, deliveryMethod, deliveryMethodOptions,
 GM> notifyOnDeliveryFailure, notifyOnPackageView, deliveryState,
deliveryType,
 GM> deliveryStateTime, deliveryTime, packageId, folderId) VALUES (?, ?, ?,
?, ?,
 GM> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); SELECT
 GM> SCOPE_IDENTITY()
 GM> 2003-06-27 20:46:49,718 DEBUG
 GM> [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.PackageUser]
 GM> Executing SQL: UPDATE MessengerPackageUser SET packageId=?, folderId=?
WHERE
 GM> packageUserId=?
 GM> 2003-06-27 20:46:49,734 DEBUG
 GM> [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.PackageUser]
Rows
 GM> affected = 1
 GM> ...
 
 GM> 2003-06-27 20:46:50,046 INFO  ...
*****************************************
 GM> 2003-06-27 20:46:50,046 INFO  ... CreateRecipient: PackageId=14
 GM> 2003-06-27 20:46:50,046 INFO  ...
*****************************************
 GM> ...
 GM> 2003-06-27 20:46:50,046 DEBUG
 GM>
[org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCSQLServerCreateCommand.PackageUse
 GM> r] Executing SQL: INSERT INTO MessengerPackageUser (pickupKey,
category,
 GM> expireTime, isSaved, recallTime, lifeCycleState, lifeCycleStateTime,
 GM> pickupTime, pickupState, pickupStateTime, streamPickupStates, address,
 GM> fullName, displayName, deliveryMethod, deliveryMethodOptions,
 GM> notifyOnDeliveryFailure, notifyOnPackageView, deliveryState,
deliveryType,
 GM> deliveryStateTime, deliveryTime, packageId, folderId) VALUES (?, ?, ?,
?, ?,
 GM> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); SELECT
 GM> SCOPE_IDENTITY()
 
 GM>  Unlike the first insert the there is no corresponding update for the
second
 GM> insert. Yet the trace message I added indicates that they where both
created
 GM> with the same package (id==14), one succeed to create the relationship
the
 GM> other didn't even try? Anyone seen anything like this before? Any ideas
on
 GM> where I should be looking?
 
 GM> thanks,
 GM> gavin

 



-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to