/** Return a transaction object for the current transaction state. */ @Override @Nonnull protected Object doGetTransaction() throws TransactionException { LOGGER.log(UjoLogger.TRACE, "GetTransaction is running"); return dummy; }
@Override protected Object doGetTransaction() throws TransactionException { LOGGER.log(UjoLogger.INFO, "getTransaction returning new Object"); //can not return null because it will not call commit return new Object(); }
private void logColumn(final ResultSet columns) throws SQLException { LOGGER.log(INFO, "DB column: {}.{}.{}.{}" , columns.getString("TABLE_CAT") , columns.getString("TABLE_SCHEM") , columns.getString("TABLE_NAME") , columns.getString("COLUMN_NAME")); }
/** Forces to reload sequence from db on next call for nextValue. */ public synchronized void reset() { sequence = 0; seqLimit = 0; maxValue = 0; LOGGER.log(UjoLogger.INFO , "{}: reset the sequencer for the table {}" , getClass().getSimpleName() , getTableName()); }
@Override public void writeValue(UjoProperty property, Object value) { // Sequence validation: if (SEQUENCE_CACHE==property) { int val = (Integer) value; if (val<1) { value = 1; final String msg = "The smallest possible value of property '"+property+"' is 1, not " + val; LOGGER.log(Level.WARNING, msg); } } super.writeValue(property, value); }
protected void beginTransaction() { LOGGER.log(UjoLogger.TRACE, "Auto transaction registred/started"); ujoSessionFactory.setAutoTransaction(true); }
@Override public void writeValue(Key key, Object value) { // Sequence validation: if (SEQUENCE_CACHE==key) { int val = (Integer) value; if (val<1) { value = 1; final String msg = "The smallest possible value of key '"+key+"' is 1, not " + val; LOGGER.log(UjoLogger.WARN, msg); } } super.writeValue(key, value); }
private static UjoLogger newUjoLoggerBridge2Slf4j(Class name) { UjoLogger result; try { result = new UjoLoggerBridge2Slf4j(name); if (showLog) { showLog = false; result.log(Level.INFO, "Ujorm logging is switched to the SLF4J."); } } catch (Throwable e) { slf4jSupport = false; result = new UjoLoggerFactory(name); result.log(Level.INFO, "Ujorm logging is switched to the JUL."); } return result; }
/** Begin a new transaction with semantics according to the given transaction */ @Override protected void doBegin(final Object tr, final TransactionDefinition td) throws TransactionException { LOGGER.log(UjoLogger.TRACE, "Auto transaction registred/started"); Session localSession = session.get(); if (localSession == null) { localSession = handler.createSession(); session.set(localSession); } localSession.beginTransaction(); }
/** Returns all model in a XML format */ @Override public String toString() { CharArrayWriter out = new CharArrayWriter(128); try { print(out); out.append("\n---\n"); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Can't export model into XML", ex); } return out.toString(); }
/** Returns all model in a XML format */ @Override public String toString() { CharArrayWriter out = new CharArrayWriter(128); try { print(out); out.append("\n---\n"); } catch (IOException ex) { LOGGER.log(UjoLogger.ERROR, "Can't export model into XML", ex); } return out.toString(); }
/** Make a commit om all databases for the current transaction level. */ public void commitTransaction() { if (transaction!=null) { transaction.commit(); } else { LOGGER.log(UjoLogger.WARN, "Transaction is not running"); commit(); } }
@Override public Session getDefaultSession() { if (!getAutoTransaction()) { LOGGER.log(UjoLogger.WARN, "geting session without autotransaction handling !!"); } return getSession(); }
@Override protected void doRollback(DefaultTransactionStatus dts) throws TransactionException { LOGGER.log(UjoLogger.WARN, "rolling back transaction"); ujoSessionFactory.getDefaultSession().rollbackTransaction(); deep = null; }
/** Make a rollback on all databases for the current transaction level. */ public void rollbackTransaction() { if (transaction!=null) { transaction.rollback(); } else { LOGGER.log(UjoLogger.WARN, "Transaction is not running"); rollback(); } }
private void doIncCalling() { if (incCalling()) { session = handler.createSession(); LOGGER.log(UjoLogger.TRACE, "opening Ujorm session"); } }
@Override protected void doCommit(DefaultTransactionStatus dts) throws TransactionException { dts.isGlobalRollbackOnly(); if (decCalling()) { LOGGER.log(UjoLogger.TRACE, "Auto transaction ending (commit/rollback)"); if (ujoSessionFactory.getDefaultSession().isRollbackOnly()) { LOGGER.log(UjoLogger.WARN, "Rolling back transaction becaouse has been mark as roll back only"); rollback(dts); return; } LOGGER.log(UjoLogger.INFO, "commiting transaction ..."); ujoSessionFactory.getDefaultSession().commitTransaction(); } }
private void doDecCalling() { if (decCalling()) { LOGGER.log(UjoLogger.TRACE, "closing Ujorm session"); getSession().close(); } }
/** Perform an actual commit of the given transaction. */ @Override protected void doCommit(@Nonnull final DefaultTransactionStatus dts) throws TransactionException { final Session localSession = getLocalSession(); final boolean rollbackOnly = dts.isGlobalRollbackOnly() || localSession.isRollbackOnly(); if (rollbackOnly) { LOGGER.log(UjoLogger.WARN, "Rolling back transaction becaouse has been mark as roll back only"); } doEnd(!rollbackOnly, localSession); }
@Override protected void doBegin(Object o, TransactionDefinition td) throws TransactionException { if (incCalling()) { LOGGER.log(UjoLogger.TRACE, "Auto transaction registred/started"); ujoSessionFactory.setAutoTransaction(true); ujoSessionFactory.getDefaultSession().beginTransaction(); } }