Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionCallback


    assertTrue(!TransactionSynchronizationManager.hasResource(factory));
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    TransactionSynchronizationManager.bindResource(factory, new EntityManagerHolder(manager));

    try {
      tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          assertTrue(TransactionSynchronizationManager.hasResource(factory));
          assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
          template.execute(new JpaCallback() {
            public Object doInJpa(EntityManager em) {
View Full Code Here


    assertTrue(!TransactionSynchronizationManager.hasResource(factory));
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    TransactionSynchronizationManager.bindResource(factory, new EntityManagerHolder(manager));

    try {
      Object result = tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          assertTrue(TransactionSynchronizationManager.hasResource(factory));
          assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
          assertTrue(!status.isNewTransaction());
          return template.execute(new JpaCallback() {
View Full Code Here

    assertTrue(!TransactionSynchronizationManager.hasResource(factory));
    assertTrue(!TransactionSynchronizationManager.isSynchronizationActive());
    TransactionSynchronizationManager.bindResource(factory, new EntityManagerHolder(manager));

    try {
      tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          assertTrue(TransactionSynchronizationManager.hasResource(factory));
          assertTrue(TransactionSynchronizationManager.isSynchronizationActive());
          assertTrue(!status.isNewTransaction());
          template.execute(new JpaCallback() {
View Full Code Here

    TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setReadOnly(readOnly);
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));

    Object result = tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        try {
          assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
          assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
          HibernateTemplate ht = new HibernateTemplate(sf);
View Full Code Here

    final List l = new ArrayList();
    l.add("test");
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));

    Object result = tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        try {
          assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
          assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
          HibernateTemplate ht = new HibernateTemplate(sf);
View Full Code Here

    final HibernateException flushEx = new HibernateException("flush failure");
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));

    try {
      tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          try {
            assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
            assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
            HibernateTemplate ht = new HibernateTemplate(sf);
View Full Code Here

    TransactionTemplate tt = new TransactionTemplate(ptm);
    final List l = new ArrayList();
    l.add("test");
    assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());

    Object result = tt.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        try {
          assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
          HibernateTemplate ht = new HibernateTemplate(sf);
          List htl = ht.executeFind(new HibernateCallback() {
View Full Code Here

      final List l = new ArrayList();
      l.add("test");
      assertTrue("JTA synchronizations not active", !TransactionSynchronizationManager.isSynchronizationActive());
      assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));

      Object result = tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          try {
            assertTrue("JTA synchronizations active", TransactionSynchronizationManager.isSynchronizationActive());
            assertTrue("Has thread session", TransactionSynchronizationManager.hasResource(sf));
            HibernateTemplate ht = new HibernateTemplate(sf);
View Full Code Here

    final TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    try {
      tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
          assertSame(session1, outerSession);
          SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
          assertTrue("Has thread session", holder != null);
          try {
            tt.execute(new TransactionCallback() {
              public Object doInTransaction(TransactionStatus status) {
                org.hibernate.Session innerSession = SessionFactoryUtils.getSession(sf, false);
                assertSame(session2, innerSession);
                HibernateTemplate ht = new HibernateTemplate(sf);
                ht.setFlushMode(HibernateTemplate.FLUSH_EAGER);
View Full Code Here

    final TransactionTemplate tt = new TransactionTemplate(ptm);
    tt.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

    assertTrue("Hasn't thread session", !TransactionSynchronizationManager.hasResource(sf));
    try {
      tt.execute(new TransactionCallback() {
        public Object doInTransaction(TransactionStatus status) {
          org.hibernate.Session outerSession = SessionFactoryUtils.getSession(sf, false);
          assertSame(session1, outerSession);
          SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sf);
          assertTrue("Has thread session", holder != null);
          tt.execute(new TransactionCallback() {
            public Object doInTransaction(TransactionStatus status) {
              return null;
            }
          });
          return null;
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.TransactionCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.