use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractConditionQuery method doRegIQ.
protected void doRegIQ(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option) {
if (!prepareQueryChecked(key, value, cvalue, columnDbName).newClause()) {
return;
}
final DBMeta dbmeta = xgetDBMetaProvider().provideDBMetaChecked(asTableDbName());
final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
final String propertyName = columnInfo.getPropertyName();
final String uncapPropName = initUncap(propertyName);
// If Java, it is necessary to use uncapPropName!
final String location = xgetLocation(uncapPropName);
key.setupConditionValue(xcreateQueryModeProvider(), cvalue, value, location, option);
final ColumnSqlName columnSqlName = columnInfo.getColumnSqlName();
final ColumnFunctionCipher cipher = xgetSqlClause().findColumnFunctionCipher(columnInfo);
if (isBaseQuery()) {
xgetSqlClause().registerBaseTableInlineWhereClause(columnSqlName, key, cvalue, cipher, option);
} else {
final String aliasName = xgetAliasName();
xgetSqlClause().registerOuterJoinInlineWhereClause(aliasName, columnSqlName, key, cvalue, cipher, option, _onClause);
}
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class HpCalcSpecification method getResolvedSpecifiedColumnDbName.
// -----------------------------------------------------
// Column Name
// -----------
/**
* @return The column DB name of specified resolved column. (NullAllowed)
*/
public String getResolvedSpecifiedColumnDbName() {
// resolved plain or deriving sub-query
checkSpecifiedCB();
if (_specifedCB.xhasDreamCruiseTicket()) {
final SpecifiedColumn ticket = _specifedCB.xshowDreamCruiseTicket();
return ticket.getColumnDbName();
}
final ColumnInfo columnInfo = getResolvedSpecifiedColumnInfo();
return columnInfo != null ? columnInfo.getColumnDbName() : null;
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class HpCalcSpecification method getResolvedSpecifiedColumnInfo.
/**
* @return The column info of specified resolved column. (NullAllowed)
*/
public ColumnInfo getResolvedSpecifiedColumnInfo() {
// resolved plain or deriving sub-query
checkSpecifiedCB();
final ColumnInfo columnInfo = getSpecifiedColumnInfo();
return columnInfo != null ? columnInfo : getSpecifiedDerivingColumnInfo();
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class DateUpdateAdjuster method truncatePrecisionOfEntityProperty.
// ===================================================================================
// DatetimePrecision Truncation
// ============================
/**
* @param entity The entity to be adjusted here. (NotNull)
*/
public void truncatePrecisionOfEntityProperty(Entity entity) {
if (entity == null) {
throw new IllegalArgumentException("The argument 'entity' should not be null.");
}
final DBMeta dbmeta = entity.asDBMeta();
final List<ColumnInfo> columnInfoList = dbmeta.getColumnInfoList();
final boolean createdBySelect = entity.createdBySelect();
if (createdBySelect) {
// to avoid non-specified column check
entity.clearMarkAsSelect();
}
try {
for (ColumnInfo columnInfo : columnInfoList) {
if (columnInfo.isObjectNativeTypeDate()) {
// it does not need to read/write if LocalDate, but no-if to be simple
// (and read/write by columnInfo does not use reflection so no worry)
// is date
final Object dateValue = columnInfo.read(entity);
if (dateValue != null) {
columnInfo.write(entity, doTruncatePrecisionIfHasTime(columnInfo, dateValue));
}
}
}
} finally {
if (createdBySelect) {
// restore
entity.markAsSelect();
}
}
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class InsertOption method xacceptInsertColumnModifiedPropertiesIfNeeds.
// -----------------------------------------------------
// Modified Properties
// -------------------
public void xacceptInsertColumnModifiedPropertiesIfNeeds(List<? extends Entity> entityList) {
// internal
if (entityList == null) {
throw new IllegalArgumentException("The argument 'entityList' should not be null.");
}
if (_insertColumnSpecification != null) {
// already specified
return;
}
if (entityList.isEmpty()) {
// do nothing
return;
}
if (xisCompatibleBatchInsertDefaultEveryColumn()) {
// every column for compatible
return;
}
final Entity firstEntity = entityList.get(0);
if (firstEntity.createdBySelect()) {
// all columns e.g. copy insert
specify(new SpecifyQuery<CB>() {
public void specify(CB cb) {
final List<ColumnInfo> infoList = firstEntity.asDBMeta().getColumnInfoList();
for (ColumnInfo info : infoList) {
if (!info.isPrimary()) {
// except PK
cb.localSp().xspecifyColumn(info.getColumnDbName());
}
}
}
});
} else {
// least common multiple or same-set columns
final Set<String> targetProps = xgatherInsertColumnModifiedProperties(entityList, firstEntity);
final DBMeta dbmeta = firstEntity.asDBMeta();
specify(new SpecifyQuery<CB>() {
public void specify(CB cb) {
// you don't need to specify primary key because primary key has special handling
for (String prop : targetProps) {
final ColumnInfo info = dbmeta.findColumnInfo(prop);
if (!info.isPrimary()) {
// except PK
cb.localSp().xspecifyColumn(info.getColumnDbName());
}
}
}
});
}
}
Aggregations