I'm using one Session across whole application, but I'm getting error:
Exception in thread "Thread-9" org.hibernate.AssertionFailure: possible non-threadsafe access to the session
This happens accidentally, not always.
In JTable model I have this:
public Object getValueAt(int rowIndex, int columnIndex) {
Invoice i = invoices.get(rowIndex);
Object[] values = new Object[] { i.getInvoiceId(), i.getIdent(),
i.getTotalExclVat(), i.getTotalInclVat(), i.getIssueDate(),
i.getTaxDate(), i.getDueDate(), i.getPayType(),
i.getWeight(), i.getSupplier().getName(),
i.getInvoiceItems().size() };
return values[columnIndex];
...
Invoice is Hibernate @Entity and @Table and it has InvoiceItems connected to it.
Question is: How should I handle Hibernate Session in Swing JTables to avoid 'possible non-threadsafe access to the session' error?
Thanks.