本文整理汇总了Java中org.seasar.doma.jdbc.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于org.seasar.doma.jdbc包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
default int delete(Invitation invitation) {
Config config = Config.get(this);
DeleteBuilder.newInstance(config)
.sql("DELETE FROM group_invitations ")
.sql("WHERE invitation_id = ")
.param(long.class, invitation.getId())
.execute();
DeleteBuilder.newInstance(config)
.sql("DELETE FROM oidc_invitations ")
.sql("WHERE invitation_id = ")
.param(long.class, invitation.getId())
.execute();
return DeleteBuilder.newInstance(config)
.sql("DELETE FROM invitations ")
.sql("WHERE invitation_id = ")
.param(long.class, invitation.getId())
.execute();
}
示例2: setUpDatabase
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@BeforeClass
public static void setUpDatabase() throws Exception {
config = new Config() {
final Dialect dialect = new H2Dialect();
@Override
public Dialect getDialect() {
return dialect;
}
@Override
public DataSource getDataSource() {
return database.getDataSource();
}
};
}
示例3: config1
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@Bean
@Foo
Config config1() {
return new Config() {
@Override
public String getDataSourceName() {
return "foo";
}
@Override
public Dialect getDialect() {
return new StandardDialect();
}
@Override
public DataSource getDataSource() {
return new SimpleDataSource();
}
};
}
示例4: config2
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@Bean
@Bar
Config config2() {
return new Config() {
@Override
public String getDataSourceName() {
return "bar";
}
@Override
public Dialect getDialect() {
return new StandardDialect();
}
@Override
public DataSource getDataSource() {
return new SimpleDataSource();
}
};
}
示例5: testGetEntityListener
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
public void testGetEntityListener() throws Exception {
Config originalConfig = new MockConfig() {
@Override
public EntityListenerProvider getEntityListenerProvider() {
return new EntityListenerProvider() {
};
}
};
RuntimeConfig runtimeConfig = new RuntimeConfig(originalConfig);
MockEntityListener entityListener = runtimeConfig
.getEntityListenerProvider().get(MockEntityListener.class,
MockEntityListener::new);
assertNotNull(entityListener);
}
示例6: prepareStatement
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
protected PreparedStatement prepareStatement(Connection connection,
PreparedSql sql) {
if (query.isAutoGeneratedKeysSupported()) {
Config config = query.getConfig();
Dialect dialect = config.getDialect();
switch (dialect.getAutoGeneratedKeysType()) {
case FIRST_COLUMN:
return JdbcUtil
.prepareStatementForAutoGeneratedKeysOfFirstColumn(
connection, sql);
case DEFAULT:
return JdbcUtil.prepareStatementForAutoGeneratedKeys(connection,
sql);
}
}
return JdbcUtil.prepareStatement(connection, sql);
}
示例7: AbstractDao
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
/**
* 実行時用の設定を作成します。
*
* @param config
* JDBCの設定
* @throws DomaNullPointerException
* {@code config} が {@code null} の場合
* @throws ConfigException
* {@code config} の メソッドのどれかが {@code null} を返す場合
*/
protected AbstractDao(Config config, Connection connection) {
if (config == null) {
throw new DomaNullPointerException("config");
}
if (connection == null) {
throw new DomaNullPointerException("connection");
}
DataSource dataSource = null;
if (connection instanceof NeverClosedConnection) {
dataSource = new NeverClosedConnectionProvider(
(NeverClosedConnection) connection);
} else {
dataSource = new NeverClosedConnectionProvider(
new NeverClosedConnection(connection));
}
validateConfig(config, dataSource);
this.__config = new RuntimeConfig(config, dataSource);
}
示例8: config
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@Bean
public Config config() {
return new Config() {
@Override
public Dialect getDialect() {
return dialect();
}
@Override
public DataSource getDataSource() {
return dataSource();
}
@Override
public SqlFileRepository getSqlFileRepository() {
return sqlFileRepository();
}
};
}
示例9: validateMethod
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
protected void validateMethod(TypeElement typeElement, String methodName) {
Optional<ExecutableElement> method = ElementFilter
.methodsIn(typeElement.getEnclosedElements())
.stream()
.filter(m -> m.getModifiers().containsAll(
EnumSet.of(Modifier.STATIC, Modifier.PUBLIC)))
.filter(m -> TypeMirrorUtil.isAssignable(m.getReturnType(),
Config.class, processingEnv))
.filter(m -> m.getParameters().isEmpty())
.filter(m -> m.getSimpleName().toString().equals(methodName))
.findAny();
if (!method.isPresent()) {
throw new AptException(Message.DOMA4254, processingEnv,
typeElement, new Object[] { methodName,
typeElement.getQualifiedName() });
}
}
示例10: selectByPassword
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
default User selectByPassword(String account, String password) {
return selectOptionallyByAccount(account)
.filter(user -> {
Config config = Config.get(this);
SelectBuilder builder = SelectBuilder.newInstance(config);
PasswordCredential credential = builder.sql("SELECT * ")
.sql("FROM password_credentials ")
.sql("WHERE user_id = ").param(Long.class, user.getId())
.getEntitySingleResult(PasswordCredential.class);
return (credential != null && Arrays.equals(
credential.getPassword(),
PasswordUtils.pbkdf2(password, credential.getSalt(), 100)));
}).orElse(null);
}
示例11: isLock
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
default boolean isLock(String account) {
Config config = Config.get(this);
SelectBuilder builder = SelectBuilder.newInstance(config);
int cnt = builder.sql("SELECT count(*) FROM user_locks UL")
.sql(" JOIN users U ON U.user_id = UL.user_id")
.sql(" WHERE")
.sql(" account = ").param(String.class, account)
.getScalarSingleResult(int.class);
return cnt > 0;
}
示例12: showConfig
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
private static void showConfig(Config config) throws Exception {
System.out.println(config);
System.out.println(config.getDialect());
System.out.println(config.getSqlFileRepository());
System.out.println(config.getNaming());
DataSource dataSource = config.getDataSource();
try (Connection con = dataSource.getConnection();
PreparedStatement pst = con.prepareStatement("select database()");
ResultSet rs = pst.executeQuery()) {
rs.next();
System.out.println(rs.getString(1));
}
}
示例13: config
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@Bean
@Primary
Config config(final EntityListenerProvider entityListenerProvider) {
final DomaConfigBuilder builder = domaProperties()
.initializeDomaConfigBuilder()
.dataSource(dataSource())
.entityListenerProvider(entityListenerProvider);
return builder.build(domaProperties());
}
示例14: secondaryConfig
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@Bean
@Secondary
Config secondaryConfig(final EntityListenerProvider entityListenerProvider) {
final DomaConfigBuilder builder = secondaryDomaProperties()
.initializeDomaConfigBuilder()
.dataSource(secondaryDataSource())
.entityListenerProvider(entityListenerProvider);
return builder.build(secondaryDomaProperties());
}
示例15: index
import org.seasar.doma.jdbc.Config; //导入依赖的package包/类
@RequestMapping(value = "/", produces = "text/plain")
String index() {
StringWriter s = new StringWriter();
try (PrintWriter out = new PrintWriter(s)) {
out.println(Config.get(fooDao).getDataSourceName());
out.println(Config.get(barDao).getDataSourceName());
}
return s.toString();
}