> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of marc
> fleury
> Sent: Wednesday, June 13, 2001 6:58 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [JBoss-dev] No storeEntity before ejbFind<METHOD>
>
>
> |boolean dirty = true;
> |if (isModified != null)
> |{
> | try
> | {
> | dirty = ((Boolean)isModified.invoke(ctx.getInstance(), new
> |Object[0])).booleanValue();
> | } catch (Exception e)
> | {
> | // Ignore
> | }
> |}
> |
> |if (dirty)
> | container.getPersistenceManager().storeEntity(ctx);
> |
> |Am I correct here? Again, let me know if you want me to check in these
> |changes...
>
> my question (you dummy) is
> do you know that the calls you make (wait my daugther just came in for a
> good-night kiss) ...
>
> do you know that that store calls you make do update the flag for
> the dirty
> check... yes I know that the dirty code is in there, which is specifically
> why I ask.
>
I'm not clear on your question, but I do check for dirtyness before I call
storeEntity.
CODE:
// EntitySynchronizationInterceptor
public Object invokeHome(MethodInvocation mi)
throws Exception
{
try {
if (mi.getTransaction() != null &&
mi.getMethod().getName().startsWith("find"))
{
// As per the spec 9.6.4, entities must be synchronized with the
datastore
// when an ejbFind<METHOD> is called.
synchronizeEntitiesWithinTransaction(mi.getTransaction());
}
return getNext().invokeHome(mi);
} finally {
// Anonymous was sent in, so if it has an id it was created
EntityEnterpriseContext ctx =
(EntityEnterpriseContext)mi.getEnterpriseContext();
if (ctx.getId() != null) {
Transaction tx = mi.getTransaction();
if (tx != null && tx.getStatus() == Status.STATUS_ACTIVE)
register(ctx, tx); // Set tx
// Currently synched with underlying storage
ctx.setValid(true);
}
}
}
/**
* As per the spec 9.6.4, entities must be synchronized with the
datastore
* when an ejbFind<METHOD> is called.
*/
private void synchronizeEntitiesWithinTransaction(Transaction tx) throws
Exception
{
Object[] entities =
((EntityContainer)getContainer()).getTxEntityMap().getEntities(tx);
for (int i = 0; i < entities.length; i++)
{
EntityEnterpriseContext ctx = (EntityEnterpriseContext)entities[i];
storeEntity(ctx);
}
}
private void storeEntity(EntityEnterpriseContext ctx) throws Exception
{
if (ctx.getId() != null)
{
boolean dirty = true;
// Check isModified bean flag
if (isModified != null)
{
dirty = ((Boolean)isModified.invoke(ctx.getInstance(), new
Object[0])).booleanValue();
}
// Store entity
if (dirty)
((EntityContainer)getContainer()).getPersistenceManager().storeEntity(ctx);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development