|
| 1 | +/* |
| 2 | + * Hibernate, Relational Persistence for Idiomatic Java |
| 3 | + * |
| 4 | + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
| 5 | + * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 6 | + */ |
| 7 | +package org.hibernate.test.flush; |
| 8 | + |
| 9 | +import java.util.Map; |
| 10 | + |
| 11 | +import javax.persistence.TransactionRequiredException; |
| 12 | + |
| 13 | +import org.hibernate.Session; |
| 14 | +import org.hibernate.cfg.AvailableSettings; |
| 15 | +import org.junit.Assert; |
| 16 | +import org.junit.Test; |
| 17 | + |
| 18 | +import org.hibernate.testing.TestForIssue; |
| 19 | +import org.hibernate.testing.jta.TestingJtaBootstrap; |
| 20 | +import org.hibernate.testing.jta.TestingJtaPlatformImpl; |
| 21 | +import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; |
| 22 | + |
| 23 | +/** |
| 24 | + * @author Michiel Hendriks |
| 25 | + */ |
| 26 | +@TestForIssue(jiraKey = "HHH-13936") |
| 27 | +public class TestFlushJoinTransaction extends BaseNonConfigCoreFunctionalTestCase { |
| 28 | + |
| 29 | + @Override |
| 30 | + protected void addSettings(Map settings) { |
| 31 | + super.addSettings( settings ); |
| 32 | + TestingJtaBootstrap.prepare( settings ); |
| 33 | + settings.put( AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta" ); |
| 34 | + } |
| 35 | + |
| 36 | + @Test |
| 37 | + public void testFlush() throws Exception { |
| 38 | + Session session = openSession(); |
| 39 | + try { |
| 40 | + TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin(); |
| 41 | + session.flush(); |
| 42 | + TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit(); |
| 43 | + } |
| 44 | + catch (TransactionRequiredException e) { |
| 45 | + Assert.fail("No TransactionRequiredException expected."); |
| 46 | + } |
| 47 | + finally { |
| 48 | + session.close(); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void testIsConnectedFlush() throws Exception { |
| 54 | + Session session = openSession(); |
| 55 | + try { |
| 56 | + TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin(); |
| 57 | + session.isConnected(); |
| 58 | + session.flush(); |
| 59 | + TestingJtaPlatformImpl.INSTANCE.getTransactionManager().commit(); |
| 60 | + } |
| 61 | + catch (TransactionRequiredException e) { |
| 62 | + Assert.fail("No TransactionRequiredException expected."); |
| 63 | + } |
| 64 | + finally { |
| 65 | + session.close(); |
| 66 | + } |
| 67 | + } |
| 68 | +} |
0 commit comments