How do you reset Spring JUnit application context after a test class dirties it?

Use @DirtiesContext to force a reset. For example I have: @ContextConfiguration(classes={BlahTestConfig.class}) @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class SomeTest { @Autowired XXXX xx; @Autowired YYYY yy; @Before public void setUp() { MockitoAnnotations.initMocks(this); when(YYYY.newYY()).thenReturn(zz); } @Test public void testSomeTest() { XX.changeSomething(“StringTest”); XX.doSomething(); check_for_effects(); } @Test public void testSomeOtherTest() { XX.changeSomething(“SomeotherString”); XX.doSomething(); check_for_effects(); } From spring docs DirtiesContext Indicates … Read more

Huge performance difference when using GROUP BY vs DISTINCT

The two queries express the same question. Apparently the query optimizer chooses two different execution plans. My guess would be that the distinct approach is executed like: Copy all business_key values to a temporary table Sort the temporary table Scan the temporary table, returning each item that is different from the one before it The … Read more

Which is better H2 or HSQLDB? [closed]

Please note I had provided this answer in 2011. It may be outdated My company develops a database abstraction library (jOOQ), which supports both databases. Our integration tests cover a lot of functionality, including the calling of stored procedures and functions, arrays, nested selects, etc. I experience HSQLDB 2.1 to be slightly faster than H2 … Read more

View content of H2 or HSQLDB in-memory database

You can run H2 web server within your application that will access the same in-memory database. You can also access the H2 running in server mode using any generic JDBC client like SquirrelSQL. UPDATE: Server webServer = Server.createWebServer(“-web,-webAllowOthers,true,-webPort,8082”).start(); Server server = Server.createTcpServer(“-tcp,-tcpAllowOthers,true,-tcpPort,9092”).start(); Now you can connect to your database via jdbc:h2:mem:foo_db URL within the same … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)