Fix for #207: Add support for PeristenceContextScope QUERY and NONE (in addition to the existing TRANSACTION scope)

This commit is contained in:
rbygrave
2014-11-20 00:53:32 +13:00
parent 55eaa0b484
commit 6677a6199c
15 changed files with 472 additions and 35 deletions
@@ -0,0 +1,38 @@
package com.avaje.tests.persistencecontext;
import com.avaje.ebean.*;
import com.avaje.ebean.config.ServerConfig;
import com.avaje.ebeaninternal.api.SpiEbeanServer;
import com.avaje.ebeaninternal.api.SpiQuery;
import com.avaje.tests.model.basic.EBasicVer;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestPersistenceContextServerConfig extends BaseTestCase {
@Test
public void test_config() {
SpiEbeanServer ebeanServer = (SpiEbeanServer)create();
Query<EBasicVer> query = ebeanServer.find(EBasicVer.class);
PersistenceContextScope scope = ebeanServer.getPersistenceContextScope((SpiQuery<?>) query);
assertEquals(PersistenceContextScope.QUERY, scope);
}
static EbeanServer create() {
ServerConfig config = new ServerConfig();
config.setName("h2");
config.loadFromProperties();
config.setName("withPCQuery");
config.setPersistenceContextScope(PersistenceContextScope.QUERY);
config.addClass(EBasicVer.class);
return EbeanServerFactory.create(config);
}
}