use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractBatchUpdateCommand method getPersistentPropertyNames.
/**
* Get persistent property names. <br>
* Basically this method should be called when initializing only.
* @param bmd The bean meta data. (NotNull)
* @return Persistent property names. (NotNull)
*/
protected String[] getPersistentPropertyNames(TnBeanMetaData bmd) {
final DBMeta dbmeta = findDBMeta();
if (dbmeta != null) {
final List<ColumnInfo> columnInfoList = dbmeta.getColumnInfoList();
final List<String> propertyNameList = new ArrayList<String>();
for (ColumnInfo columnInfo : columnInfoList) {
propertyNameList.add(columnInfo.getPropertyName());
}
return propertyNameList.toArray(new String[] {});
} else {
// when the entity does not have its DB meta.
return createNonOrderedPropertyNames(bmd);
}
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractCountableUpdateCommand method getPersistentPropertyNames.
/**
* Get persistent property names. <br>
* Basically this method should be called when initializing only.
* @param bmd The bean meta data. (NotNull)
* @return Persistent property names. (NotNull)
*/
protected String[] getPersistentPropertyNames(TnBeanMetaData bmd) {
final DBMeta dbmeta = findDBMeta();
if (dbmeta != null) {
final List<ColumnInfo> columnInfoList = dbmeta.getColumnInfoList();
final List<String> propertyNameList = new ArrayList<String>();
for (ColumnInfo columnInfo : columnInfoList) {
propertyNameList.add(columnInfo.getPropertyName());
}
return propertyNameList.toArray(new String[] {});
} else {
// when the entity does not have its DB meta.
return createNonOrderedPropertyNames(bmd);
}
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class TnBeanListResultSetHandler method createRelationSelector.
/**
* Create the selector of relation.
* @param hasCB Does the select use condition-bean?
* @param cb The condition-bean for the select. (NullAllowed: not condition-bean select)
* @return The created selector instance. (NotNull)
*/
protected TnRelationSelector createRelationSelector(final boolean hasCB, ConditionBean cb) {
final boolean undefClsSel = isUndefinedClassificationSelectAllowed(hasCB, cb);
final boolean colNullObj = isUseColumnNullObjectHandling(hasCB, cb);
return new TnRelationSelector() {
public boolean isNonLimitMapping() {
return hasCB;
}
public boolean isNonSelectedRelation(String relationNoSuffix) {
return hasCB && !cb.getSqlClause().hasSelectedRelation(relationNoSuffix);
}
public boolean isNonSelectedNextConnectingRelation(String relationNoSuffix) {
return hasCB && !cb.getSqlClause().isSelectedNextConnectingRelation(relationNoSuffix);
}
public boolean canUseRelationCache(String relationNoSuffix) {
return hasCB && cb.getSqlClause().canUseRelationCache(relationNoSuffix);
}
public boolean isNonSpecifiedColumnAccessAllowed(String relationNoSuffix) {
return hasCB && cb.isNonSpecifiedColumnAccessAllowed();
}
public boolean isUsingSpecifyColumnInRelation(String relationNoSuffix) {
if (!hasCB) {
return false;
}
final SqlClause sqlClause = cb.getSqlClause();
final String tableAlias = sqlClause.translateSelectedRelationPathToTableAlias(relationNoSuffix);
if (tableAlias == null) {
// no way but just in case
return false;
}
return sqlClause.hasSpecifiedSelectColumn(tableAlias);
}
public Set<ColumnInfo> getRelationSpecifiedNullObjectColumnSet(String relationNoSuffix) {
if (!hasCB) {
return DfCollectionUtil.emptySet();
}
return cb.getSqlClause().getRelationSpecifiedNullObjectColumnSet(relationNoSuffix);
}
public boolean isUndefinedClassificationSelectAllowed(String relationNoSuffix) {
return undefClsSel;
}
public boolean isColumnNullObjectEnabled(String relationNoSuffix) {
return colNullObj;
}
};
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class TnRelationPropertyTypeImpl method deriveUniqueKeys.
protected List<TnPropertyType> deriveUniqueKeys(String[] yourKeys, TnBeanMetaData yourBeanMetaData) {
final DBMeta dbmeta = yourBeanMetaData.getDBMeta();
final List<TnPropertyType> uniquePropertyTypeList;
if (dbmeta != null && dbmeta.hasPrimaryKey()) {
final PrimaryInfo primaryInfo = dbmeta.getPrimaryInfo();
final List<ColumnInfo> primaryColumnList = primaryInfo.getPrimaryColumnList();
uniquePropertyTypeList = new ArrayList<TnPropertyType>(primaryColumnList.size());
for (ColumnInfo pk : primaryColumnList) {
final TnPropertyType pt = yourBeanMetaData.getPropertyTypeByColumnName(pk.getColumnDbName());
uniquePropertyTypeList.add(pt);
}
} else {
uniquePropertyTypeList = new ArrayList<TnPropertyType>(yourKeys.length);
for (String yourKey : yourKeys) {
final TnPropertyType pt = yourBeanMetaData.getPropertyTypeByColumnName(yourKey);
uniquePropertyTypeList.add(pt);
}
}
return uniquePropertyTypeList;
}
use of org.dbflute.dbmeta.info.ColumnInfo in project dbflute-core by dbflute.
the class AbstractConditionQuery method doInvokeQuery.
protected void doInvokeQuery(String colName, String ckey, Object value, ConditionOption option) {
assertStringNotNullAndNotTrimmedEmpty("columnFlexibleName", colName);
assertStringNotNullAndNotTrimmedEmpty("conditionKeyName", ckey);
final boolean noArg = Srl.equalsIgnoreCase(ckey, "IsNull", "IsNotNull", "IsNullOrEmpty", "EmptyString");
if (!noArg && (value == null || "".equals(value))) {
if (xgetSqlClause().isNullOrEmptyQueryChecked()) {
// as default
String msg = "The conditionValue is required but null or empty: column=" + colName + " value=" + value;
throw new IllegalConditionBeanOperationException(msg);
} else {
// e.g. when cb.ignoreNullOrEmptyQuery()
return;
}
}
final PropertyNameCQContainer container = xhelpExtractingPropertyNameCQContainer(colName);
final String flexibleName = container.getFlexibleName();
final ConditionQuery cq = container.getConditionQuery();
final DBMeta dbmeta = findDBMeta(cq.asTableDbName());
final ColumnInfo columnInfo;
try {
columnInfo = dbmeta.findColumnInfo(flexibleName);
} catch (RuntimeException e) {
throwConditionInvokingColumnFindFailureException(colName, ckey, value, option, e);
// unreachable (to avoid compile error)
return;
}
final String columnCapPropName = initCap(columnInfo.getPropertyName());
final boolean rangeOf = Srl.equalsIgnoreCase(ckey, "RangeOf");
final boolean fromTo = Srl.equalsIgnoreCase(ckey, "FromTo", "DateFromTo");
final boolean inScope = Srl.equalsIgnoreCase(ckey, "InScope");
if (!noArg) {
try {
// convert type
value = columnInfo.convertToObjectNativeType(value);
} catch (RuntimeException e) {
throwConditionInvokingValueConvertFailureException(colName, ckey, value, option, e);
}
}
final String methodName = xbuildQuerySetMethodName(ckey, columnCapPropName);
final List<Class<?>> typeList = newArrayListSized(4);
final Class<?> propertyType = columnInfo.getObjectNativeType();
if (fromTo) {
if (LocalDate.class.isAssignableFrom(propertyType)) {
// #date_parade
typeList.add(propertyType);
typeList.add(propertyType);
} else if (LocalDateTime.class.isAssignableFrom(propertyType)) {
typeList.add(propertyType);
typeList.add(propertyType);
} else {
// fixedly util.Date
typeList.add(Date.class);
typeList.add(Date.class);
}
} else if (rangeOf) {
typeList.add(propertyType);
typeList.add(propertyType);
} else {
if (!noArg) {
final Class<?> instanceType = value.getClass();
if (inScope && Collection.class.isAssignableFrom(instanceType)) {
// double check just in case
// inScope's argument is fixed type
typeList.add(Collection.class);
} else {
typeList.add(instanceType);
}
}
}
if (option != null) {
typeList.add(option.getClass());
}
final List<Class<?>> filteredTypeList = newArrayListSized(typeList.size());
for (Class<?> parameterType : typeList) {
filteredTypeList.add(xfilterInvokeQueryParameterType(colName, ckey, parameterType));
}
final Class<?>[] parameterTypes = filteredTypeList.toArray(new Class<?>[filteredTypeList.size()]);
final Method method = xhelpGettingCQMethod(cq, methodName, parameterTypes);
if (method == null) {
throwConditionInvokingSetMethodNotFoundException(colName, ckey, value, option, methodName, parameterTypes);
}
try {
final List<Object> argList = newArrayList();
if (fromTo || rangeOf) {
if (!(value instanceof List<?>)) {
// check type
throwConditionInvokingDateFromToValueInvalidException(colName, ckey, value, option, methodName, parameterTypes);
}
argList.addAll((List<?>) value);
} else {
if (!noArg) {
argList.add(value);
}
}
if (option != null) {
argList.add(option);
}
final List<Object> filteredArgList = newArrayListSized(argList.size());
for (Object arg : argList) {
filteredArgList.add(xfilterInvokeQueryParameterValue(colName, ckey, arg));
}
xhelpInvokingCQMethod(cq, method, filteredArgList.toArray());
} catch (ReflectionFailureException e) {
throwConditionInvokingSetReflectionFailureException(colName, ckey, value, option, methodName, parameterTypes, e);
}
}
Aggregations