use of org.dbflute.dbmeta.DBMeta 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.DBMeta 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.DBMeta 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.DBMeta in project dbflute-core by dbflute.
the class TnRelationPropertyTypeImpl method createPropertyAccessor.
protected DfPropertyAccessor createPropertyAccessor(final DfPropertyDesc propertyDesc, TnBeanMetaData myBeanMetaData) {
final DBMeta dbmeta = myBeanMetaData.getDBMeta();
assertDBMetaExists(dbmeta, myBeanMetaData);
final String propertyName = propertyDesc.getPropertyName();
final ForeignInfo foreignInfo = dbmeta.hasForeign(propertyName) ? dbmeta.findForeignInfo(propertyName) : null;
return new DfPropertyAccessor() {
public String getPropertyName() {
return foreignInfo != null ? foreignInfo.getForeignPropertyName() : propertyName;
}
public Class<?> getPropertyType() {
return foreignInfo != null ? foreignInfo.getPropertyAccessType() : propertyDesc.getPropertyType();
}
public Class<?> getGenericType() {
return propertyDesc.getGenericType();
}
public Object getValue(Object target) {
if (foreignInfo != null && target instanceof Entity) {
// basically here
return foreignInfo.read((Entity) target);
} else {
return propertyDesc.getValue(target);
}
}
public void setValue(Object target, Object value) {
if (foreignInfo != null && target instanceof Entity) {
// basically here
foreignInfo.write((Entity) target, value);
} else {
propertyDesc.setValue(target, value);
}
}
public boolean isReadable() {
return propertyDesc.isReadable();
}
public boolean isWritable() {
return propertyDesc.isWritable();
}
};
}
use of org.dbflute.dbmeta.DBMeta in project dbflute-core by dbflute.
the class AbstractConditionQuery method invokeOrderBy.
/**
* {@inheritDoc}
*/
public void invokeOrderBy(String columnFlexibleName, boolean isAsc) {
assertStringNotNullAndNotTrimmedEmpty("columnFlexibleName", columnFlexibleName);
final PropertyNameCQContainer container = xhelpExtractingPropertyNameCQContainer(columnFlexibleName);
final String flexibleName = container.getFlexibleName();
final ConditionQuery cq = container.getConditionQuery();
final String ascDesc = isAsc ? "Asc" : "Desc";
final DBMeta dbmeta = findDBMeta(cq.asTableDbName());
final String columnCapPropName = initCap(dbmeta.findColumnInfo(flexibleName).getPropertyName());
final String methodName = "addOrderBy_" + columnCapPropName + "_" + ascDesc;
final Method method = xhelpGettingCQMethod(cq, methodName, (Class<?>[]) null);
if (method == null) {
throwConditionInvokingOrderMethodNotFoundException(columnFlexibleName, isAsc, methodName);
}
try {
xhelpInvokingCQMethod(cq, method, (Object[]) null);
} catch (ReflectionFailureException e) {
throwConditionInvokingOrderReflectionFailureException(columnFlexibleName, isAsc, methodName, e);
}
}
Aggregations