cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Multiple open receipts for current user

former_member333938
Participant
0 Kudos
353

hello all,

I am very often had this error: "Multiple open receipts for current user!", when I get the receipt on screen like this:

cdbSession = CDBSessionFactory.instance.createSession(); 

receiptManager = ServiceFactory.INSTANCE.getOrCreateServiceInstance(ReceiptPosService.class, cdbSession);

receipt = receiptManager.findOrCreate(UserRegistry.INSTANCE.getCurrentUser(), null, true);

I can't identify what causes it, and I'm closing the CDBSession that I create.

if(!cdbSession.isClosed())
    cdbSession.closeDBSession();

I am getting the receipt object in the method:

@PluginAt(pluginClass = OrderPosService.class, method = "finishOrder", where = POSITION.BEFORE)

Anyone knows how to solve this?

Accepted Solutions (0)

Answers (1)

Answers (1)

R_Zieschang
Contributor
0 Kudos

Hi josehrmatos,

dont open another db session when you're hooked in a PosService. Permanently! Don't do it.

The posService is the object, you will get as "proxy". This service should have a method called getDbSession().

public void onFinishOrder(Object proxy, Object[] args, Object ret, StackTraceElement caller) {
   OrderPosService posService = (OrderPosService) proxy;
   CDBSession session = posService.getDbSession();
   ...

}

When you open another db session some strange side effects will occur!

Regards

Robert

former_member333938
Participant
0 Kudos

Hi rzieschang,thanks for answering.

I am getting the session through the proxy:

CDBSession cdbSession =  ((OrderPosService) proxy).getDbSession();

but it still gives me the same error. The strange thing is that it only happens in table mode, it works well in quick service mode.