/** * Return the join from the field table to the owning class table. */ public ForeignKey getJoin(final FieldMapping field, Table table, boolean adapt) { // if we have no join columns defined, check class-level join // if the given field is embedded then consider primary table of owner return getJoin(field, table, adapt, getColumns()); }
/** * Return the join from the field table to the owning class table. */ public ForeignKey getJoin(final FieldMapping field, Table table, boolean adapt) { // if we have no join columns defined, check class-level join // if the given field is embedded then consider primary table of owner return getJoin(field, table, adapt, getColumns()); }
/** * Return the join from the field table to the owning class table. */ public ForeignKey getJoin(final FieldMapping field, Table table, boolean adapt) { // if we have no join columns defined, check class-level join // if the given field is embedded then consider primary table of owner return getJoin(field, table, adapt, getColumns()); }
/** * Return the join from the field table to the owning class table. */ public ForeignKey getJoin(final FieldMapping field, Table table, boolean adapt) { // if we have no join columns defined, check class-level join // if the given field is embedded then consider primary table of owner return getJoin(field, table, adapt, getColumns()); }
/** * Parse join-column. */ private boolean startJoinColumn(Attributes attrs) throws SAXException { // only join cols in a join table join field table to class table; // others act as data fk cols Object currentParent = currentParent(); if (currentParent == COLLECTION_TABLE) { FieldMapping fm = (FieldMapping) peekElement(); Column col = parseColumn(attrs); List<Column> colList = fm.getMappingInfo().getColumns(); if (colList.isEmpty()) { colList = new ArrayList<Column>(); fm.getMappingInfo().setColumns(colList); } colList.add(col); fm.getMappingInfo().setColumns(colList); return true; } if (currentParent != JOIN_TABLE) return startColumn(attrs); if (_joinCols == null) _joinCols = new ArrayList<Column>(3); _joinCols.add(parseColumn(attrs)); return true; }
/** * Parse join-column. */ private boolean startJoinColumn(Attributes attrs) throws SAXException { // only join cols in a join table join field table to class table; // others act as data fk cols Object currentParent = currentParent(); if (currentParent == COLLECTION_TABLE) { FieldMapping fm = (FieldMapping) peekElement(); Column col = parseColumn(attrs); List<Column> colList = fm.getMappingInfo().getColumns(); if (colList.isEmpty()) { colList = new ArrayList<Column>(); fm.getMappingInfo().setColumns(colList); } colList.add(col); fm.getMappingInfo().setColumns(colList); return true; } if (currentParent != JOIN_TABLE) return startColumn(attrs); if (_joinCols == null) _joinCols = new ArrayList<Column>(3); _joinCols.add(parseColumn(attrs)); return true; }
/** * Return the join from the field table to the owning class table. */ public ForeignKey getJoin(final FieldMapping field, Table table, boolean adapt) { // if we have no join columns defined, check class-level join List cols = getColumns(); if (cols.isEmpty()) cols = field.getDefiningMapping().getMappingInfo(). getSecondaryTableJoinColumns(_tableName); ForeignKeyDefaults def = new ForeignKeyDefaults() { public ForeignKey get(Table local, Table foreign, boolean inverse) { return field.getMappingRepository().getMappingDefaults(). getJoinForeignKey(field, local, foreign); } public void populate(Table local, Table foreign, Column col, Object target, boolean inverse, int pos, int cols) { field.getMappingRepository().getMappingDefaults(). populateJoinColumn(field, local, foreign, col, target, pos, cols); } }; ClassMapping cls = field.getDefiningMapping(); return createForeignKey(field, "join", cols, def, table, cls, cls, false, adapt); }
/** * Parse join-column. */ private boolean startJoinColumn(Attributes attrs) throws SAXException { // only join cols in a join table join field table to class table; // others act as data fk cols Object currentParent = currentParent(); if (currentParent == COLLECTION_TABLE) { FieldMapping fm = (FieldMapping) peekElement(); Column col = parseColumn(attrs); List<Column> colList = fm.getMappingInfo().getColumns(); if (colList.isEmpty()) { colList = new ArrayList<Column>(); fm.getMappingInfo().setColumns(colList); } colList.add(col); fm.getMappingInfo().setColumns(colList); return true; } if (currentParent != JOIN_TABLE) return startColumn(attrs); if (_joinCols == null) _joinCols = new ArrayList<Column>(3); _joinCols.add(parseColumn(attrs)); return true; }
/** * Return the table for the given field, or null if no table given. */ public Table getTable(final FieldMapping field, boolean create, boolean adapt) { if (_tableName == null && !create) return null; Table table = field.getDefiningMapping().getTable(); String schemaName = (table == null) ? null : table.getSchema().getName(); // if we have no join columns defined, there may be class-level join // information with a more fully-qualified name for our table String tableName = _tableName; if (tableName != null && getColumns().isEmpty()) tableName = field.getDefiningMapping().getMappingInfo(). getSecondaryTableName(tableName); return createTable(field, new TableDefaults() { public String get(Schema schema) { // delay this so that we don't do schema reflection for unique // table name unless necessary return field.getMappingRepository().getMappingDefaults(). getTableName(field, schema); } }, schemaName, tableName, adapt); }
/** * Use hints in mapping data to figure out whether the given relation * field should use an inverse foreign key or an association table mapping. */ private boolean useInverseKeyMapping(FieldMapping field) { FieldMapping mapped = field.getMappedByMapping(); if (mapped != null) { if (mapped.getTypeCode() == JavaTypes.PC) return true; if (mapped.getElement().getTypeCode() == JavaTypes.PC) return false; throw new MetaDataException(_loc.get("bad-mapped-by", field, mapped)); } // without a mapped-by, we have to look for clues as to the mapping. // we assume that anything with element foreign key columns but no join // columns or table uses an inverse foreign key, and anything else uses // an association table FieldMappingInfo info = field.getMappingInfo(); ValueMapping elem = field.getElementMapping(); return info.getTableName() == null && info.getColumns().isEmpty() && !elem.getValueInfo().getColumns().isEmpty(); }
/** * Return the table for the given field, or null if no table given. */ public Table getTable(final FieldMapping field, boolean create, boolean adapt) { if (DBIdentifier.isNull(_tableName) && !create) return null; Table table = field.getDefiningMapping().getTable(); DBIdentifier schemaName = (table == null) ? DBIdentifier.NULL : table.getSchema().getIdentifier(); // if we have no join columns defined, there may be class-level join // information with a more fully-qualified name for our table DBIdentifier tableName = _tableName; if (!DBIdentifier.isNull(tableName) && getColumns().isEmpty()) tableName = field.getDefiningMapping().getMappingInfo(). getSecondaryTableIdentifier(tableName); return createTable(field, new TableDefaults() { public String get(Schema schema) { // delay this so that we don't do schema reflection for unique // table name unless necessary return field.getMappingRepository().getMappingDefaults(). getTableName(field, schema); } public DBIdentifier getIdentifier(Schema schema) { return field.getMappingRepository().getMappingDefaults(). getTableIdentifier(field, schema); } }, schemaName, tableName, adapt); }
/** * Return the table for the given field, or null if no table given. */ public Table getTable(final FieldMapping field, boolean create, boolean adapt) { if (DBIdentifier.isNull(_tableName) && !create) return null; Table table = field.getDefiningMapping().getTable(); DBIdentifier schemaName = (table == null) ? DBIdentifier.NULL : table.getSchema().getIdentifier(); // if we have no join columns defined, there may be class-level join // information with a more fully-qualified name for our table DBIdentifier tableName = _tableName; if (!DBIdentifier.isNull(tableName) && getColumns().isEmpty()) tableName = field.getDefiningMapping().getMappingInfo(). getSecondaryTableIdentifier(tableName); return createTable(field, new TableDefaults() { public String get(Schema schema) { // delay this so that we don't do schema reflection for unique // table name unless necessary return field.getMappingRepository().getMappingDefaults(). getTableName(field, schema); } public DBIdentifier getIdentifier(Schema schema) { return field.getMappingRepository().getMappingDefaults(). getTableIdentifier(field, schema); } }, schemaName, tableName, adapt); }
/** * Return the table for the given field, or null if no table given. */ public Table getTable(final FieldMapping field, boolean create, boolean adapt) { if (DBIdentifier.isNull(_tableName) && !create) return null; Table table = field.getDefiningMapping().getTable(); DBIdentifier schemaName = (table == null) ? DBIdentifier.NULL : table.getSchema().getIdentifier(); // if we have no join columns defined, there may be class-level join // information with a more fully-qualified name for our table DBIdentifier tableName = _tableName; if (!DBIdentifier.isNull(tableName) && getColumns().isEmpty()) tableName = field.getDefiningMapping().getMappingInfo(). getSecondaryTableIdentifier(tableName); return createTable(field, new TableDefaults() { public String get(Schema schema) { // delay this so that we don't do schema reflection for unique // table name unless necessary return field.getMappingRepository().getMappingDefaults(). getTableName(field, schema); } public DBIdentifier getIdentifier(Schema schema) { // TODO Auto-generated method stub return field.getMappingRepository().getMappingDefaults(). getTableIdentifier(field, schema); } }, schemaName, tableName, adapt); }
boolean useInverseKeyMapping = DBIdentifier.isNull(info.getTableIdentifier()) && info.getColumns().isEmpty() && !elem.getValueInfo().getColumns().isEmpty();
boolean useInverseKeyMapping = DBIdentifier.isNull(info.getTableIdentifier()) && info.getColumns().isEmpty() && !elem.getValueInfo().getColumns().isEmpty();
boolean useInverseKeyMapping = DBIdentifier.isNull(info.getTableIdentifier()) && info.getColumns().isEmpty() && !elem.getValueInfo().getColumns().isEmpty();
public void setBi1MJoinTableInfo() { if (getAssociationType() == FieldMetaData.ONE_TO_MANY) { FieldMapping mapped = getBi_MTo1_JTField(); if (mapped != null) { FieldMappingInfo info = getMappingInfo(); FieldMappingInfo mappedInfo = mapped.getMappingInfo(); info.setTableIdentifier(mappedInfo.getTableIdentifier()); info.setColumns(mapped.getElementMapping().getValueInfo().getColumns()); getElementMapping().getValueInfo().setColumns( mappedInfo.getColumns()); } } }
public void setBi1MJoinTableInfo() { if (getAssociationType() == FieldMetaData.ONE_TO_MANY) { FieldMapping mapped = getBi_MTo1_JTField(); if (mapped != null) { FieldMappingInfo info = getMappingInfo(); FieldMappingInfo mappedInfo = mapped.getMappingInfo(); info.setTableIdentifier(mappedInfo.getTableIdentifier()); info.setColumns(mapped.getElementMapping().getValueInfo().getColumns()); getElementMapping().getValueInfo().setColumns( mappedInfo.getColumns()); } } }
public void setBi1MJoinTableInfo() { if (getAssociationType() == FieldMetaData.ONE_TO_MANY) { FieldMapping mapped = getBi_MTo1_JTField(); if (mapped != null) { FieldMappingInfo info = getMappingInfo(); FieldMappingInfo mappedInfo = mapped.getMappingInfo(); info.setTableIdentifier(mappedInfo.getTableIdentifier()); info.setColumns(mapped.getElementMapping().getValueInfo().getColumns()); getElementMapping().getValueInfo().setColumns( mappedInfo.getColumns()); } } }
public void setBi1MJoinTableInfo() { if (getAssociationType() == FieldMetaData.ONE_TO_MANY) { FieldMapping mapped = getBi_MTo1_JTField(); if (mapped != null) { FieldMappingInfo info = getMappingInfo(); FieldMappingInfo mappedInfo = mapped.getMappingInfo(); info.setTableIdentifier(mappedInfo.getTableIdentifier()); info.setColumns(mapped.getElementMapping().getValueInfo().getColumns()); getElementMapping().getValueInfo().setColumns( mappedInfo.getColumns()); } } }