Yeah thanks ! I had figured it out, but how do you get your
"transactional context" ?

I ended up doing the following, in case someone else needs to do the same:

within a class...

public void deleteSession(StatefulKnowledgeSession session)
        {
                initTransactionManager();
                this.txm.begin();

                registerRollbackSync();

                SessionInfo info =
jpm.getApplicationScopedEntityManager().find(org.drools.persistence.session.SessionInfo.class,
new Integer(session.getId()));
                System.out.println("This is the sessionInfo: " + info);
                jpm.getApplicationScopedEntityManager().remove(info);
                jpm.getApplicationScopedEntityManager().flush();

                this.txm.commit();
        }

private void initTransactionManager() {
                Object tm = environment.get( 
EnvironmentName.TRANSACTION_MANAGER );
                this.txm = new JtaTransactionManager( environment.get(
EnvironmentName.TRANSACTION ),
                                environment.get( 
EnvironmentName.TRANSACTION_SYNCHRONIZATION_REGISTRY ),
                                tm );
                this.jpm = new DefaultJpaManager(this.environment);

        }


private static class SynchronizationImpl
        implements
        TransactionSynchronization {

                JPAKnowledgeSessionLookup service = getInstance();
                public SynchronizationImpl(JPAKnowledgeSessionLookup service) {
            this.service = service;
        }
                
                public void afterCompletion(int status) {
                        if ( status != TransactionManager.STATUS_COMMITTED ) {
                                this.service.rollback();
                        }


                        this.service.jpm.endCommandScopedEntityManager();

                }

                public void beforeCompletion() {

                }

        }

Thanks

On Wed, Sep 15, 2010 at 1:33 PM, drooRam <[email protected]> wrote:
>
> I have done something like below to remove the persisted session :
>
>                SessionInfo si = em.find(SessionInfo.class, sessionId);
>                em.remove(si);
>
> call the above lines in a transactional context. its done.
> --
> View this message in context: 
> http://drools-java-rules-engine.46999.n3.nabble.com/How-to-remove-a-persisted-session-from-the-database-tp1473926p1481588.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to