congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DbJtxSessionProvider
Code IndexAdd Tabnine to your IDE (free)

How to use
DbJtxSessionProvider
in
jodd.db.jtx

Best Java code snippets using jodd.db.jtx.DbJtxSessionProvider (Showing top 16 results out of 315)

origin: oblac/jodd

@Test
void testRequiredToNever() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: required
  JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertNotNull(jtx);
  DbSession session1 = sessionProvider.getDbSession();
  executeUpdate(session1, "insert into GIRL values(1, 'Sophia', null)");
  assertTrue(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  // session #2: inner, never
  try {
    worker.maybeRequestTransaction(never(), CTX_2);
    fail("error");
  } catch (JtxException ignore) {
  }
}
origin: oblac/jodd

final DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);
origin: org.jodd/jodd-joy

final DbSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);
origin: oblac/jodd

@Test
void testSupportsToMandatory() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: supports
  JtxTransaction jtx = worker.maybeRequestTransaction(supports(), CTX_1);
  assertNotNull(jtx);
  assertFalse(jtx.isActive());
  DbSession session1 = sessionProvider.getDbSession();
  executeUpdate(session1, "insert into GIRL values(1, 'Sophia', null)");
  assertFalse(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertTrue(jtx.isNoTransaction());
  // session #2: inner, mandatory
  try {
    worker.maybeRequestTransaction(mandatory(), CTX_2);
    fail("error");
  } catch (JtxException ignore) {
  }
}
origin: oblac/jodd

@Test
void testSupportsNone() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: supports - commit
  JtxTransaction jtx = worker.maybeRequestTransaction(supports(), CTX_1);
  assertNotNull(jtx);
  DbSession session = sessionProvider.getDbSession();
  executeUpdate(session, "insert into GIRL values(1, 'Sophia', null)");
  assertFalse(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertTrue(jtx.isNoTransaction());
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  // session #2: required - rollback
  jtx = worker.maybeRequestTransaction(supports(), CTX_2);
  assertNotNull(jtx);
  session = sessionProvider.getDbSession();
  executeUpdate(session, "insert into GIRL values(2, 'Gloria', null)");
  assertTrue(worker.markOrRollbackTransaction(jtx, null));
  // test
  session = new DbSession(cp);
  assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 1"));
  assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 2"));
  session.closeSession();
}
origin: oblac/jodd

@Test
void testRequiredToSupportsCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: required
  JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertNotNull(jtx);
  DbSession session1 = sessionProvider.getDbSession();
  executeUpdate(session1, "insert into GIRL values(1, 'Sophia', null)");
  assertTrue(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  // session #2: inner, supports
  JtxTransaction jtx2 = worker.maybeRequestTransaction(supports(), CTX_2);
  assertNull(jtx2);
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
  assertFalse(worker.maybeCommitTransaction(jtx2));
  assertTrue(jtx.isActive());
  // session #1: commit
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  // test
  session1 = new DbSession(cp);
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 1"));
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 2"));
  session1.closeSession();
}
origin: oblac/jodd

@Test
void testNotSupported() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: not supported - commit
  JtxTransaction jtx = worker.maybeRequestTransaction(notSupported(), CTX_1);
  assertNotNull(jtx);
  DbSession session = sessionProvider.getDbSession();
  executeUpdate(session, "insert into GIRL values(1, 'Sophia', null)");
  assertFalse(jtx.isActive());
  assertTrue(jtx.isNoTransaction());
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  // session #2: not supported - rollback
  jtx = worker.maybeRequestTransaction(notSupported(), CTX_2);
  assertNotNull(jtx);
  session = sessionProvider.getDbSession();
  assertFalse(jtx.isActive());
  assertTrue(jtx.isNoTransaction());
  executeUpdate(session, "insert into GIRL values(2, 'Gloria', null)");
  assertTrue(worker.markOrRollbackTransaction(jtx, null));
  // test
  session = new DbSession(cp);
  assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 1"));
  assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 2"));
  session.closeSession();
}
origin: oblac/jodd

@Test
void testRequiredToMandatoryCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: required
  JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertNotNull(jtx);
  DbSession session1 = sessionProvider.getDbSession();
  executeUpdate(session1, "insert into GIRL values(1, 'Sophia', null)");
  assertTrue(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  // session #2: inner, mandatory
  JtxTransaction jtx2 = worker.maybeRequestTransaction(mandatory(), CTX_2);
  assertNull(jtx2);
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
  assertFalse(worker.maybeCommitTransaction(jtx2));
  assertTrue(jtx.isActive());
  // session #1: commit
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  // test
  session1 = new DbSession(cp);
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 1"));
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 2"));
  session1.closeSession();
}
origin: oblac/jodd

@Test
void testRequiredToRequiredCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: required
  JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertNotNull(jtx);
  DbSession session1 = sessionProvider.getDbSession();
  executeUpdate(session1, "insert into GIRL values(1, 'Sophia', null)");
  assertTrue(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  // session #2: inner, required
  JtxTransaction jtx2 = worker.maybeRequestTransaction(required(), CTX_2);
  assertNull(jtx2);
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
  assertFalse(worker.maybeCommitTransaction(jtx2));
  assertTrue(jtx.isActive());
  // session #1: commit
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  // test
  session1 = new DbSession(cp);
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 1"));
  assertEquals(1, executeCount(session1, "select count(*) from GIRL where id = 2"));
  session1.closeSession();
}
origin: oblac/jodd

@Test
void testRequired() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  // session #1: required - commit
  JtxTransaction jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertTrue(jtx.isActive());
  assertNotNull(jtx);
  DbSession session = sessionProvider.getDbSession();
  executeUpdate(session, "insert into GIRL values(1, 'Sophia', null)");
  assertTrue(jtx.isActive());
  assertFalse(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  assertTrue(worker.maybeCommitTransaction(jtx));
  assertFalse(jtx.isActive());
  assertTrue(jtx.isCommitted());
  assertFalse(jtx.isNoTransaction());
  // session #2: required - rollback
  jtx = worker.maybeRequestTransaction(required(), CTX_1);
  assertNotNull(jtx);
  session = sessionProvider.getDbSession();
  executeUpdate(session, "insert into GIRL values(2, 'Gloria', null)");
  assertTrue(worker.markOrRollbackTransaction(jtx, null));
  // test
  session = new DbSession(cp);
  assertEquals(1, executeCount(session, "select count(*) from GIRL where id = 1"));
  assertEquals(0, executeCount(session, "select count(*) from GIRL where id = 2"));
  session.closeSession();
}
origin: oblac/jodd

@Test
void testSupportsToRequiredCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  assertNotNull(jtx);
  assertFalse(jtx.isActive());
  DbSession session1 = sessionProvider.getDbSession();
  DbSession session2 = sessionProvider.getDbSession();
  assertNotSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
origin: oblac/jodd

@Test
void testSupportsToSupportsCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  assertNotNull(jtx);
  assertFalse(jtx.isActive());
  DbSession session1 = sessionProvider.getDbSession();
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
origin: oblac/jodd

@Test
void testSupportsToNeverCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  assertNotNull(jtx);
  assertFalse(jtx.isActive());
  DbSession session1 = sessionProvider.getDbSession();
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
origin: oblac/jodd

@Test
void testSupportsToRequiresNewCommit() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  assertNotNull(jtx);
  assertFalse(jtx.isActive());
  DbSession session1 = sessionProvider.getDbSession();
  DbSession session2 = sessionProvider.getDbSession();
  assertNotSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
origin: oblac/jodd

@Test
void testRequiredToRequiredRollback() {
  LeanJtxWorker worker = new LeanJtxWorker(dbtxm);
  DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(worker.getTransactionManager());
  DbSession session1 = sessionProvider.getDbSession();
  DbSession session2 = sessionProvider.getDbSession();
  assertSame(session1, session2);
  executeUpdate(session2, "insert into GIRL values(2, 'Gloria', null)");
origin: oblac/jodd

DbJtxSessionProvider sessionProvider = new DbJtxSessionProvider(jtxManager);
  DbSession dbSession = sessionProvider.getDbSession();
  assertNotNull(dbSession);
  DbSession dbSession2 = sessionProvider.getDbSession();
  assertNotNull(dbSession2);
  assertSame(dbSession, dbSession2);
jodd.db.jtxDbJtxSessionProvider

Javadoc

Returns session from the db JtxTransactionManager, like DbJtxTransactionManager.

Most used methods

  • <init>
    Creates new JTX session provider.
  • getDbSession
    Returns session from JTX transaction manager and started transaction.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • findViewById (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JOptionPane (javax.swing)
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now