use of org.seasar.doma.jdbc.dialect.Dialect in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_mssql_nowait.
@Test
void forUpdate_mssql_nowait() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new MssqlDialect();
}
});
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).where(c -> c.eq(e.id, 1)).forUpdate(ForUpdateOption.noWait()).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ with (updlock, rowlock, nowait) where t0_.ID = 1", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.Dialect in project doma by domaframework.
the class NativeSqlSelectTest method expression_concat_mssql2008.
@Test
void expression_concat_mssql2008() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new Mssql2008Dialect();
}
});
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).select(concat(e.name, "a"));
Sql<?> sql = stmt.asSql();
assertEquals("select (t0_.NAME + 'a') from EMP t0_", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.Dialect in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_oracle_nowait.
@Test
void forUpdate_oracle_nowait() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new OracleDialect();
}
});
Emp_ e = new Emp_();
Buildable<?> stmt = nativeSql.from(e).forUpdate(ForUpdateOption.noWait()).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ for update nowait", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.Dialect in project doma by domaframework.
the class NativeSqlSelectTest method forUpdate_oracle_wait_withColumn.
@Test
void forUpdate_oracle_wait_withColumn() {
NativeSql nativeSql = new NativeSql(new MockConfig() {
@Override
public Dialect getDialect() {
return new OracleDialect();
}
});
Emp_ e = new Emp_();
Dept_ d = new Dept_();
Buildable<?> stmt = nativeSql.from(e).innerJoin(d, on -> on.eq(e.id, d.id)).forUpdate(ForUpdateOption.wait(5, e.id, d.id)).select(e.id);
Sql<?> sql = stmt.asSql();
assertEquals("select t0_.ID from EMP t0_ inner join CATA.DEPT t1_ on (t0_.ID = t1_.ID) for update of t0_.ID, t1_.ID wait 5", sql.getFormattedSql());
}
use of org.seasar.doma.jdbc.dialect.Dialect in project doma by domaframework.
the class AutoDeleteQuery method prepareSql.
protected void prepareSql() {
Naming naming = config.getNaming();
Dialect dialect = config.getDialect();
PreparedSqlBuilder builder = new PreparedSqlBuilder(config, SqlKind.DELETE, sqlLogType);
builder.appendSql("delete from ");
builder.appendSql(entityType.getQualifiedTableName(naming::apply, dialect::applyQuote));
boolean whereClauseAppended = false;
if (idPropertyTypes.size() > 0) {
builder.appendSql(" where ");
whereClauseAppended = true;
for (EntityPropertyType<ENTITY, ?> propertyType : idPropertyTypes) {
Property<ENTITY, ?> property = propertyType.createProperty();
property.load(entity);
builder.appendSql(propertyType.getColumnName(naming::apply, dialect::applyQuote));
builder.appendSql(" = ");
builder.appendParameter(property.asInParameter());
builder.appendSql(" and ");
}
builder.cutBackSql(5);
}
if (versionPropertyType != null && !versionIgnored) {
if (whereClauseAppended) {
builder.appendSql(" and ");
} else {
builder.appendSql(" where ");
whereClauseAppended = true;
}
Property<ENTITY, ?> property = versionPropertyType.createProperty();
property.load(entity);
builder.appendSql(versionPropertyType.getColumnName(naming::apply, dialect::applyQuote));
builder.appendSql(" = ");
builder.appendParameter(property.asInParameter());
}
if (tenantIdPropertyType != null) {
if (whereClauseAppended) {
builder.appendSql(" and ");
} else {
builder.appendSql(" where ");
// noinspection UnusedAssignment
whereClauseAppended = true;
}
Property<ENTITY, ?> property = tenantIdPropertyType.createProperty();
property.load(entity);
builder.appendSql(tenantIdPropertyType.getColumnName(naming::apply, dialect::applyQuote));
builder.appendSql(" = ");
builder.appendParameter(property.asInParameter());
}
sql = builder.build(this::comment);
}
Aggregations