AnghelLeonard
AnghelLeonard
Reputation Top 1%
AnghelLeonard
9 Snippets  (95th place)
Published
1 Channel
Created
0 Channels
Following
207 points  (145th place)
Reputation
Junior Code Generator
Serious Code Generator
Junior Publisher
Serious Publisher
Junior Trend Maker
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Junior Snip2Coder
Serious Famous Coder
Junior Wise Coder

Recent Snippets See all snippets by AnghelLeonard

public by AnghelLeonard  212358  3  5  0

Hibernate JPA - programmatically set the transaction isolation level for the current connection

Hibernate JPA - programmatically set the transaction isolation level for the current connection
entityManager = entityManagerFactory.createEntityManager();
            Session session = (Session) entityManager.getDelegate();            
            session.doWork((Connection connection) -> {
                connection.setTransactionIsolation(
                        Connection.TRANSACTION_READ_COMMITTED);
            });
;

public by AnghelLeonard  1755  0  5  0

Execute a Hibernate SQLQuery via EntityManager

Execute a Hibernate SQLQuery via EntityManager
List results = ((Session)this.entityManager.getDelegate()).createSQLQuery(
                "SELECT a.name AS namep, b.name AS names, c.name AS namet"
                        + " FROM secondarycategory b"
                        + " INNER JOIN topcategory a ON a.id=b.top_id"
                        + " INNER JOIN thirdcategory c ON b.id=c.secondary_id").list();
;

public by AnghelLeonard  1423  0  5  0

SpringBoot H2 in file

SpringBoot H2 in file
spring.datasource.url = jdbc:h2:~/foo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username = sa
spring.datasource.password =
;

public by AnghelLeonard  1371  0  5  0

JUnit4 Test Suite

JUnit4 Test Suite
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({ FooTest.class, BuzzTest.class, BizzTest.class })
public class TestSuite {
}
;

public by AnghelLeonard  1539  0  5  0

JUnit 4 test an exception

JUnit 4 test an exception
@Test(expected=RuntimeException.class)
public void fooTest() {
 throw new RuntimeException();
}
;