use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.
the class AbstractConditionBean method xdoSetupSelectDreamCruiseJourneyLogBook.
protected void xdoSetupSelectDreamCruiseJourneyLogBook() {
// small waste exists but simple logic is best here
final ConditionBean departurePort = xgetDreamCruiseDeparturePort();
for (String relationPath : _dreamCruiseJourneyLogBook) {
// e.g. _2_5
final List<String> relNoExpList = Srl.splitList(relationPath, "_");
final StringBuilder sb = new StringBuilder();
DBMeta currentMeta = asDBMeta();
int index = 0;
for (String relNoExp : relNoExpList) {
if ("".equals(relNoExp)) {
continue;
}
final Integer relationNo = Integer.valueOf(relNoExp);
final ForeignInfo foreignInfo = currentMeta.findForeignInfo(relationNo);
final String foreignPropertyName = foreignInfo.getForeignPropertyName();
if (index > 0) {
sb.append(".");
}
sb.append(foreignPropertyName);
currentMeta = foreignInfo.getForeignDBMeta();
++index;
}
departurePort.invokeSetupSelect(sb.toString());
}
}
use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.
the class AbstractConditionQuery method xbuildForeignCorrelatedFixedCondition.
protected String xbuildForeignCorrelatedFixedCondition(ConditionQuery subQuery, String relationPropertyName) {
if (relationPropertyName == null) {
return null;
}
final DBMeta localDBMeta = xgetLocalDBMeta();
final RelationInfo relationInfo = localDBMeta.findRelationInfo(relationPropertyName);
if (!relationInfo.isReferrer()) {
return null;
}
if (!(relationInfo instanceof ReferrerInfo)) {
return null;
}
final ReferrerInfo referrerInfo = (ReferrerInfo) relationInfo;
return xdoBuildReferrerCorrelatedFixedCondition(subQuery, referrerInfo);
}
use of org.dbflute.dbmeta.DBMeta 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.DBMeta in project dbflute-core by dbflute.
the class HpAbstractSpecification method getColumnInfoList.
// -----------------------------------------------------
// Assist Helper
// -------------
protected List<ColumnInfo> getColumnInfoList() {
final String tableDbName = _query.asTableDbName();
final DBMeta dbmeta = _dbmetaProvider.provideDBMeta(tableDbName);
return dbmeta.getColumnInfoList();
}
use of org.dbflute.dbmeta.DBMeta 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();
}
}
}
Aggregations