本文整理汇总了Java中org.databene.commons.ObjectNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java ObjectNotFoundException类的具体用法?Java ObjectNotFoundException怎么用?Java ObjectNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectNotFoundException类属于org.databene.commons包,在下文中一共展示了ObjectNotFoundException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importSchemas
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public void importSchemas(Database database) throws SQLException {
LOGGER.debug("Importing schemas from environment '{}'", database.getEnvironment());
StopWatch watch = new StopWatch("importSchemas");
int schemaCount = 0;
ResultSet schemaSet = metaData.getSchemas();
while (schemaSet.next()) {
String schemaName = schemaSet.getString(1);
String catalogName = null;
int columnCount = schemaSet.getMetaData().getColumnCount();
if (columnCount >= 2)
catalogName = schemaSet.getString(2);
if (schemaName.equalsIgnoreCase(this.schemaName)
|| (this.schemaName == null && dialect.isDefaultSchema(schemaName, user))) {
LOGGER.debug("importing schema {}", StringUtil.quoteIfNotNull(schemaName));
this.schemaName = schemaName; // take over capitalization used in the DB
String catalogNameOfSchema = (columnCount >= 2 && catalogName != null ? catalogName : this.catalogName); // PostgreSQL and SQL Server do not necessarily tell you the catalog name
DBCatalog catalogOfSchema = database.getCatalog(catalogNameOfSchema);
if (catalogOfSchema == null)
throw new ObjectNotFoundException("Catalog not found: " + catalogOfSchema);
new DBSchema(schemaName, catalogOfSchema);
schemaCount++;
} else
LOGGER.debug("ignoring schema {}", StringUtil.quoteIfNotNull(schemaName));
}
if (schemaCount == 0) {
// add a default schema if none was reported (e.g. by MySQL)
DBCatalog catalogToUse = database.getCatalog(catalogName);
if (catalogToUse == null)
catalogToUse = database.getCatalogs().get(0);
catalogToUse.addSchema(new DBSchema(null));
}
schemaSet.close();
watch.stop();
}
示例2: getTable
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBTable getTable(String name, boolean required) {
for (DBSchema schema : getSchemas())
for (DBTable table : schema.getTables())
if (table.getName().equals(name))
return table;
if (required)
throw new ObjectNotFoundException("Table '" + name + "'");
else
return null;
}
示例3: parseFK
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
private static DBForeignKeyConstraint parseFK(String spec, Database database) {
spec = spec.trim();
int iBracket = spec.indexOf('(');
String tableName = spec.substring(0, iBracket);
String columnList = spec.substring(iBracket + 1, spec.length() - 1);
String[] columns = StringUtil.splitAndTrim(columnList, ',');
DBTable refererTable = database.getTable(tableName, true);
DBForeignKeyConstraint fk = refererTable.getForeignKeyConstraint(columns);
if (fk == null)
throw new ObjectNotFoundException("Foreign ke constraint not found: " + tableName +
'(' + ArrayFormat.format(columns) + ')');
return fk;
}
示例4: columnReferencedBy
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public String columnReferencedBy(String fkColumnName, boolean required) {
int index = ArrayUtil.indexOf(fkColumnName, fkColumnNames);
if (index < 0) {
if (required)
throw new ObjectNotFoundException("foreign key '" + name + "' does not have a column '" + fkColumnName + "'");
else
return null;
}
return refereeColumnNames[index];
}
示例5: getSchema
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBSchema getSchema(String schemaName) {
for (DBCatalog catalog : getCatalogs()) {
DBSchema schema = catalog.getSchema(schemaName);
if (schema != null)
return schema;
}
throw new ObjectNotFoundException("Table '" + name + "'");
}
示例6: getTable
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBTable getTable(String name, boolean required) {
for (DBCatalog catalog : getCatalogs())
for (DBTable table : catalog.getTables())
if (StringUtil.equalsIgnoreCase(table.getName(), name))
return table;
if (required)
throw new ObjectNotFoundException("Table '" + name + "'");
else
return null;
}
示例7: getColumn
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBColumn getColumn(String columnName) {
haveColumnsImported();
DBColumn column = columns.get(columnName);
if (column == null)
throw new ObjectNotFoundException("Column '" + columnName +
"' not found in table '" + this.getName() + "'");
return column;
}
示例8: getForeignKeyConstraint
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBForeignKeyConstraint getForeignKeyConstraint(String... columnNames) {
haveFKsImported();
for (DBForeignKeyConstraint fk : foreignKeyConstraints)
if (StringUtil.equalsIgnoreCase(fk.getColumnNames(), columnNames))
return fk;
throw new ObjectNotFoundException("Table '" + name + "' has no foreign key " +
"with the columns (" + ArrayFormat.format(columnNames) + ")");
}
示例9: queryByPK
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBRow queryByPK(Object pk, Connection connection, DatabaseDialect dialect) throws SQLException {
String[] pkColumnNames = getPrimaryKeyConstraint().getColumnNames();
if (pkColumnNames.length == 0)
throw new ObjectNotFoundException("Table " + name + " has no primary key");
Object[] pkComponents = (pk.getClass().isArray() ? (Object[]) pk : new Object[] { pk });
String whereClause = SQLUtil.renderWhereClause(pkColumnNames, pkComponents, dialect);
DBRowIterator iterator = new DBRowIterator(this, connection, whereClause);
if (!iterator.hasNext())
throw new ObjectNotFoundException("No " + name + " row with id (" + pkComponents + ")");
DBRow result = iterator.next();
iterator.close();
return result;
}
示例10: getSequence
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBSequence getSequence(String sequenceName, Connection connection) throws SQLException {
DBSequence[] sequences = querySequences(connection);
for (DBSequence seq : sequences)
if (seq.getName().equalsIgnoreCase(sequenceName))
return seq;
throw new ObjectNotFoundException("No sequence found with name '" + sequenceName + "'");
}
示例11: getTable
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public DBTable getTable(String tableName) {
parseMetadataIfNecessary();
DBTable table = findTableInConfiguredCatalogAndSchema(tableName);
if (table != null)
return table;
table = findAnyTableOfName(tableName);
if (table != null) {
logger.warn("Table '" + tableName + "' not found " +
"in the expected catalog '" + catalogName + "' and schema '" + schemaName + "'. " +
"I have taken it from catalog '" + table.getCatalog() + "' and schema '" + table.getSchema() + "' instead. " +
"You better make sure this is right and fix the configuration");
return table;
}
throw new ObjectNotFoundException("Table " + tableName);
}
示例12: assertNext
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public static void assertNext(ResultSet resultSet, String query)
throws SQLException {
if (!resultSet.next())
throw new ObjectNotFoundException("Database query did not return a result: " + query);
}
示例13: getIdentity
import org.databene.commons.ObjectNotFoundException; //导入依赖的package包/类
public IdentityModel getIdentity(String tableName, boolean required) {
IdentityModel result = identities.get(tableName);
if (required && (result == null || result instanceof NoIdentity))
throw new ObjectNotFoundException("No identity defined for table '" + tableName + "'");
return result;
}