本文整理汇总了Java中org.apache.cayenne.map.DbEntity类的典型用法代码示例。如果您正苦于以下问题:Java DbEntity类的具体用法?Java DbEntity怎么用?Java DbEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbEntity类属于org.apache.cayenne.map包,在下文中一共展示了DbEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTableModel
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
static Table createTableModel(DatabaseChannel channel, DbEntity dbEntity) {
Column[] columns = new Column[dbEntity.getAttributes().size()];
int i = 0;
for (DbAttribute a : dbEntity.getAttributes()) {
columns[i++] = new Column(Objects.requireNonNull(a.getName()), a.getType());
}
// ensure predictable column order .. DbEntity's attributes are presumably already sorted, but just in case
Arrays.sort(columns, (c1, c2) -> c1.getName().compareTo(c2.getName()));
return Table.builder(channel, dbEntity.getFullyQualifiedName())
.columns(columns)
.quoteSqlIdentifiers(dbEntity.getDataMap().isQuotingSQLIdentifiers())
.build();
}
示例2: tablesInInsertOrder
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
static Table[] tablesInInsertOrder(BQRuntime runtime, Collection<DbEntity> dbEntities) {
// note: do not obtain sorter from Cayenne DI. It is not a singleton and will come
// uninitialized
ServerRuntime serverRuntime = runtime.getInstance(ServerRuntime.class);
EntitySorter sorter = serverRuntime.getDataDomain().getEntitySorter();
List<DbEntity> list = new ArrayList<>(dbEntities);
sorter.sortDbEntities(list, false);
DatabaseChannel channel = DatabaseChannel.get(runtime);
Table[] tables = new Table[list.size()];
for (int i = 0; i < tables.length; i++) {
tables[i] = createTableModel(channel, list.get(i));
}
return tables;
}
示例3: getRelatedDbEntities
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
static Stream<DbEntity> getRelatedDbEntities(EntityResolver resolver, Class<?> entityType, Property<?> relationship) {
ObjEntity entity = resolver.getObjEntity(entityType);
if (entity == null) {
throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
}
ObjRelationship objRelationship = entity.getRelationship(relationship.getName());
if (objRelationship == null) {
throw new IllegalArgumentException("No relationship '" + relationship.getName() + "' in entity " + entityType.getName());
}
List<DbRelationship> path = objRelationship.getDbRelationships();
if (path.size() < 2) {
return Stream.empty();
}
return path.subList(1, path.size()).stream().map(DbRelationship::getSourceEntity);
}
示例4: checkCreateFull
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
private boolean checkCreateFull(DataNode dataNode) throws SQLException {
Map<String, Boolean> nameTables = getNameTablesInDB(dataNode);
Collection<DbEntity> entities = dataNode.getEntityResolver().getDbEntities();
for (DbEntity entity : entities) {
if (nameTables.get(entity.getName()) != null) {
return false;
}
}
generateFull(dataNode);
return true;
}
示例5: DatabaseEntityAdapter
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
public DatabaseEntityAdapter(final DbEntity databaseEntity)
{
// Must be assigned before property binding.
this.databaseEntity = databaseEntity;
try
{
nameProperty = bindString(DATAASE_ENTITY_NAME);
}
catch (final NoSuchMethodException e)
{
throw new RuntimeException("Fix the builder.", e);
}
}
示例6: display
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
@Deprecated // Unused?
public void display(final DbEntity dbEntity)
{
LOGGER.debug("trying to display: " + dbEntity);
// attributesTableView.setItems(FXCollections.observableArrayList(objEntity.getAttributes()));
// objectEntityClassTabViewController.display(objEntity);
// objEntity.getAttributes()
}
示例7: getPkName
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
/**
* Return the database primary key column name for the given data object.
*
* @param dataObjectClass the class of the data object
* @return the primary key column name
*/
protected String getPkName(Class dataObjectClass) {
Validate.notNull(dataObjectClass, "Null dataObjectClass parameter.");
ObjEntity objEntity =
getDataContext().getEntityResolver().lookupObjEntity(dataObjectClass);
if (objEntity == null) {
throw new CayenneRuntimeException("Unmapped DataObject Class: "
+ dataObjectClass.getName());
}
DbEntity dbEntity = objEntity.getDbEntity();
if (dbEntity == null) {
throw new CayenneRuntimeException("No DbEntity for ObjEntity: "
+ objEntity.getName());
}
List pkAttributes = dbEntity.getPrimaryKey();
if (pkAttributes.size() != 1) {
throw new CayenneRuntimeException("PK contains "
+ pkAttributes.size()
+ " columns, expected 1.");
}
DbAttribute attr = (DbAttribute) pkAttributes.get(0);
return attr.getName();
}
示例8: build
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
public CayenneTestDataManager build() {
Set<DbEntity> mergedEntities = mergeEntities();
return new CayenneTestDataManager(
runtime.getInstance(ServerRuntime.class).getDataDomain(),
runtime.getInstance(CayenneTableManager.class),
deleteData,
refreshCayenneCaches,
CayenneModelUtils.tablesInInsertOrder(runtime, mergedEntities));
}
示例9: mergeEntities
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
private Set<DbEntity> mergeEntities() {
if(dbEntityGraphRoots.isEmpty()) {
return dbEntities;
}
Set<DbEntity> merged = ModelDependencyResolver.resolve(dbEntityGraphRoots);
merged.addAll(dbEntities);
return merged;
}
示例10: getDbEntity
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
static DbEntity getDbEntity(EntityResolver resolver, Class<?> entityType) {
ObjEntity entity = resolver.getObjEntity(entityType);
if (entity == null) {
throw new IllegalArgumentException("Not a Cayenne entity class: " + entityType.getName());
}
if (entity.getDbEntityName() == null) {
throw new IllegalArgumentException("Cayenne entity class is not mapped to a DbEntity: " + entityType.getName());
}
return entity.getDbEntity();
}
示例11: getTable
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
public Table getTable(String name) {
return tables.computeIfAbsent(name, n -> {
DbEntity entity = resolver.getDbEntity(n);
if (entity == null) {
throw new IllegalArgumentException("Unknown DbEntity: " + n);
}
return CayenneModelUtils.createTableModel(channel, entity);
});
}
示例12: isPrimaryKey
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
/**
* @return true if all PK columns are represented in {@code keys}
*/
private boolean isPrimaryKey(DbEntity entity, Collection<String> keys) {
Collection<DbAttribute> pks = entity.getPrimaryKeys();
for (DbAttribute pk : pks) {
if (!keys.contains(pk.getName())) {
return false;
}
}
return true;
}
示例13: DatabaseEntityTreeViewModel
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
public DatabaseEntityTreeViewModel(final DbEntity dbEntity)
{
this.dbEntity = dbEntity;
}
示例14: getValue
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
public DbEntity getValue()
{
return dbEntity;
}
示例15: resolve
import org.apache.cayenne.map.DbEntity; //导入依赖的package包/类
static Set<DbEntity> resolve(Collection<DbEntity> entities) {
Set<DbEntity> resolved = new HashSet<>();
entities.forEach(e -> resolve(resolved, e));
return resolved;
}