本文整理汇总了Java中io.ebean.EbeanServer类的典型用法代码示例。如果您正苦于以下问题:Java EbeanServer类的具体用法?Java EbeanServer怎么用?Java EbeanServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EbeanServer类属于io.ebean包,在下文中一共展示了EbeanServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindings
import io.ebean.EbeanServer; //导入依赖的package包/类
@Override
public Seq<Binding<?>> bindings(Environment environment, Configuration configuration) {
Binding<EbeanServer> ebeanBinding = bind(EbeanServer.class)
.qualifiedWith(PushServicesEbeanServer.class)
.toProvider(PushServicesEbeanServerProvider.class);
Binding<ApplicationLifecycleListener> lifecycleBinding = bind(ApplicationLifecycleListener.class)
.toProvider(PushApplicationLifecycleProvider.class)
.eagerly();
Binding<TaskQueueScheduler> taskqueueBinding = bind(TaskQueueScheduler.class)
.toSelf();
return seq(ebeanBinding, lifecycleBinding, taskqueueBinding);
}
示例2: cleanDB
import io.ebean.EbeanServer; //导入依赖的package包/类
private void cleanDB() throws SQLException {
EbeanServer server = Ebean.getServer("default");
DropAllDdlGenerator generator = new DropAllDdlGenerator((SpiEbeanServer)server, new ServerConfig());
// Drop
Database db = getDB();
Statement statement = db.getConnection().createStatement();
try {
statement.executeUpdate("delete from play_evolutions");
statement.close();
} catch (SQLException e) {
// OK
}
db.shutdown();
generator.runScript(false, generator.generateDropDdl(), "drop all");
}
示例3: NativeEbeanQuery
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates a new {@link NativeEbeanQuery} encapsulating the query annotated on the given {@link EbeanQueryMethod}.
*
* @param method must not be {@literal null}.
* @param ebeanServer must not be {@literal null}.
* @param queryString must not be {@literal null} or empty.
* @param evaluationContextProvider
*/
public NativeEbeanQuery(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {
super(method, ebeanServer, queryString, evaluationContextProvider, parser);
Parameters<?, ?> parameters = method.getParameters();
boolean hasPagingOrSortingParameter = parameters.hasPageableParameter() || parameters.hasSortParameter();
boolean containsPageableOrSortInQueryExpression = queryString.contains("#pageable")
|| queryString.contains("#sort");
if (hasPagingOrSortingParameter && !containsPageableOrSortInQueryExpression) {
throw new InvalidEbeanQueryMethodException(
"Cannot use native queries with dynamic sorting and/or pagination in method " + method);
}
}
示例4: create
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates a {@link QueryLookupStrategy} for the given {@link EbeanServer} and {@link Key}.
*
* @param ebeanServer must not be {@literal null}.
* @param key may be {@literal null}.
* @param evaluationContextProvider must not be {@literal null}.
* @return
*/
public static QueryLookupStrategy create(EbeanServer ebeanServer, Key key,
EvaluationContextProvider evaluationContextProvider) {
Assert.notNull(ebeanServer, "EbeanServer must not be null!");
Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");
switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
case CREATE:
return new CreateQueryLookupStrategy(ebeanServer);
case USE_DECLARED_QUERY:
return new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider);
case CREATE_IF_NOT_FOUND:
return new CreateIfNotFoundQueryLookupStrategy(ebeanServer, new CreateQueryLookupStrategy(ebeanServer),
new DeclaredQueryLookupStrategy(ebeanServer, evaluationContextProvider));
default:
throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
}
}
示例5: resolveQuery
import io.ebean.EbeanServer; //导入依赖的package包/类
@Override
protected RepositoryQuery resolveQuery(EbeanQueryMethod method, EbeanServer ebeanServer, NamedQueries namedQueries) {
RepositoryQuery query = EbeanQueryFactory.INSTANCE.fromQueryAnnotation(method, ebeanServer, evaluationContextProvider);
if (null != query) {
return query;
}
String name = method.getNamedQueryName();
if (namedQueries.hasQuery(name)) {
return EbeanQueryFactory.INSTANCE.fromMethodWithQueryString(method, ebeanServer, namedQueries.getQuery(name),
evaluationContextProvider);
}
query = NamedEbeanQuery.lookupFrom(method, ebeanServer);
if (null != query) {
return query;
}
throw new IllegalStateException(
String.format("Did neither find a NamedQuery nor an annotated query for method %s!", method));
}
示例6: NativeEbeanUpdate
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates a new {@link NativeEbeanUpdate} encapsulating the query annotated on the given {@link EbeanQueryMethod}.
*
* @param method must not be {@literal null}.
* @param ebeanServer must not be {@literal null}.
* @param queryString must not be {@literal null} or empty.
* @param evaluationContextProvider
*/
public NativeEbeanUpdate(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {
super(method, ebeanServer, queryString, evaluationContextProvider, parser);
Parameters<?, ?> parameters = method.getParameters();
boolean hasPagingOrSortingParameter = parameters.hasPageableParameter() || parameters.hasSortParameter();
boolean containsPageableOrSortInQueryExpression = queryString.contains("#pageable")
|| queryString.contains("#sort");
if (hasPagingOrSortingParameter && !containsPageableOrSortInQueryExpression) {
throw new InvalidEbeanQueryMethodException(
"Cannot use native queries with dynamic sorting and/or pagination in method " + method);
}
}
示例7: exampleExpression
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Return a ExampleExpression from Spring data Example
*
* @param ebeanServer
* @param example
* @param <T>
* @return
*/
public static <T> ExampleExpression exampleExpression(EbeanServer ebeanServer, Example<T> example) {
LikeType likeType;
switch (example.getMatcher().getDefaultStringMatcher()) {
case EXACT:
likeType = LikeType.EQUAL_TO;
break;
case CONTAINING:
likeType = LikeType.CONTAINS;
break;
case STARTING:
likeType = LikeType.STARTS_WITH;
break;
case ENDING:
likeType = LikeType.ENDS_WITH;
break;
default:
likeType = LikeType.RAW;
break;
}
return ebeanServer.getExpressionFactory().exampleLike(example.getProbe(),
example.getMatcher().isIgnoreCaseEnabled(),
likeType);
}
示例8: ProcessNested
import io.ebean.EbeanServer; //导入依赖的package包/类
public ProcessNested(EbeanServer server, BeanType<T> desc, BulkUpdate txn, UpdateNested nested) {
this.server = server;
this.desc = desc;
this.txn = txn;
this.nested = nested;
this.fullNestedPath = nested.getPath();
beanDocType = desc.docStore();
String[] nestedPathSplit = getTopNestedPath(fullNestedPath);
this.nestedPath = nestedPathSplit[0];
this.nestedIdProperty = nestedPathSplit[1];
this.nestedDoc = beanDocType.getEmbedded(this.nestedPath);
this.nestedDesc = desc.getBeanTypeAtPath(this.nestedPath);
this.nestedProperty = desc.getProperty(nestedPath);
this.nestedMany = nestedProperty.isMany();
if (nestedMany) {
manyRootDoc = beanDocType.getEmbeddedManyRoot(nestedPath);
}
this.selectId = createSelectId(desc);
this.nestedIdPropertyName = nestedDesc.getIdProperty().getName();
}
示例9: getObject
import io.ebean.EbeanServer; //导入依赖的package包/类
@Override
public EbeanServer getObject() throws Exception {
ServerConfig config = new ServerConfig();
config.setName("db");
config.setCurrentUserProvider(currentUser);
// // set the spring's datasource and transaction manager.
// config.setDataSource(dataSource);
// config.setExternalTransactionManager(new SpringAwareJdbcTransactionManager());
config.loadFromProperties();
// set as default and register so that Model can be
// used if desired for save() and update() etc
config.setDefaultServer(true);
config.setRegister(true);
return EbeanServerFactory.create(config);
}
示例10: insert_via_server
import io.ebean.EbeanServer; //导入依赖的package包/类
@Test
public void insert_via_server() {
BasicConfigurator.configure();
Human being = null;
being = new Human();
being.setAge(12);
being.setFirstName("I");
being.setLastName("be human");
being.setUserId(1L);
being.setGender("m");
EbeanServer server = Ebean.getDefaultServer();
server.beginTransaction();
server.save(being);
server.commitTransaction();
assertNotNull(being.getAge());
Query<Human> find = server.find(Human.class);
Human findOne = find.findOne();
System.out.println(findOne.getAge());
}
示例11: testWithoutInitial
import io.ebean.EbeanServer; //导入依赖的package包/类
@Test
public void testWithoutInitial() {
// Setup
Long magicBeanId = Long.valueOf(47L);
EbeanServer mock = Mockito.mock(EbeanServer.class);
when(mock.getBeanId(null)).thenReturn(magicBeanId);
// Start mock Ebean session
MockiEbean mockiEbean = MockiEbean.start(mock);
try {
// So using the Ebean singleton returns the mock instance
EbeanServer server = Ebean.getServer(null);
Object beanId = server.getBeanId(null);
assertEquals(magicBeanId, beanId);
} finally {
// restore Ebean default server
mockiEbean.restoreOriginal();
}
EbeanServer restoredServer = Ebean.getServer(null);
assertTrue("is a real EbeanServer", restoredServer instanceof DefaultServer);
}
示例12: stop
import io.ebean.EbeanServer; //导入依赖的package包/类
@Test
public void stop() throws Exception {
new MockUnit(Config.class, ServerConfig.class, EbeanServer.class)
.expect(createEbean)
.expect(withoutDdl)
.expect(unit -> {
EbeanServer ebean = unit.get(EbeanServer.class);
ebean.shutdown(false, false);
})
.run(unit -> {
EbeanManaged managed = new EbeanManaged(unit.get(Config.class),
unit.get(ServerConfig.class));
managed.stop();
// ignored
managed.stop();
});
}
示例13: AbstractStringBasedEbeanQuery
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates a new {@link AbstractStringBasedEbeanQuery} from the given {@link EbeanQueryMethod}, {@link io.ebean.EbeanServer} and
* query {@link String}.
*
* @param method must not be {@literal null}.
* @param ebeanServer must not be {@literal null}.
* @param queryString must not be {@literal null}.
* @param evaluationContextProvider must not be {@literal null}.
* @param parser must not be {@literal null}.
*/
public AbstractStringBasedEbeanQuery(EbeanQueryMethod method, EbeanServer ebeanServer, String queryString,
EvaluationContextProvider evaluationContextProvider, SpelExpressionParser parser) {
super(method, ebeanServer);
Assert.hasText(queryString, "Query string must not be null or empty!");
Assert.notNull(evaluationContextProvider, "ExpressionEvaluationContextProvider must not be null!");
Assert.notNull(parser, "Parser must not be null or empty!");
this.evaluationContextProvider = evaluationContextProvider;
this.query = new ExpressionBasedStringQuery(queryString, method.getEntityInformation(), parser);
this.parser = parser;
}
示例14: createEbeanQuery
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates an appropriate Ebean query from an {@link EbeanServer} according to the current {@link AbstractEbeanQuery}
* type.
*
* @param queryString
* @return
*/
protected Object createEbeanQuery(String queryString) {
EbeanServer ebeanServer = getEbeanServer();
ResultProcessor resultFactory = getQueryMethod().getResultProcessor();
ReturnedType returnedType = resultFactory.getReturnedType();
return ebeanServer.createQuery(returnedType.getReturnedType(), queryString);
}
示例15: PartTreeEbeanQuery
import io.ebean.EbeanServer; //导入依赖的package包/类
/**
* Creates a new {@link PartTreeEbeanQuery}.
*
* @param method must not be {@literal null}.
* @param ebeanServer must not be {@literal null}.
*/
public PartTreeEbeanQuery(EbeanQueryMethod method, EbeanServer ebeanServer) {
super(method, ebeanServer);
this.domainClass = method.getEntityInformation().getJavaType();
this.tree = new PartTree(method.getName(), domainClass);
this.parameters = (DefaultParameters) method.getParameters();
this.queryPreparer = new QueryPreparer(ebeanServer);
}