/** build join formula */ public static Ejb3JoinColumn buildJoinFormula( JoinFormula ann, String mappedBy, Map<String, Join> joins, PropertyHolder propertyHolder, String propertyName, MetadataBuildingContext buildingContext) { Ejb3JoinColumn formulaColumn = new Ejb3JoinColumn(); formulaColumn.setFormula(ann.value()); formulaColumn.setReferencedColumn(ann.referencedColumnName()); formulaColumn.setBuildingContext(buildingContext); formulaColumn.setPropertyHolder(propertyHolder); formulaColumn.setJoins(joins); formulaColumn.setPropertyName(BinderHelper.getRelativePath(propertyHolder, propertyName)); formulaColumn.bind(); return formulaColumn; }
// TODO default name still useful in association table public void setJoinAnnotation(JoinColumn annJoin, String defaultName) { if (annJoin == null) { setImplicit(true); } else { setImplicit(false); if (!BinderHelper.isEmptyAnnotationValue(annJoin.columnDefinition())) { setSqlType( getBuildingContext() .getObjectNameNormalizer() .applyGlobalQuoting(annJoin.columnDefinition())); } if (!BinderHelper.isEmptyAnnotationValue(annJoin.name())) { setLogicalColumnName(annJoin.name()); } setNullable(annJoin.nullable()); setUnique(annJoin.unique()); setInsertable(annJoin.insertable()); setUpdatable(annJoin.updatable()); setReferencedColumn(annJoin.referencedColumnName()); if (BinderHelper.isEmptyAnnotationValue(annJoin.table())) { setExplicitTableName(""); } else { final Identifier logicalIdentifier = getBuildingContext().getMetadataCollector().getDatabase().toIdentifier(annJoin.table()); final Identifier physicalIdentifier = getBuildingContext() .getBuildingOptions() .getPhysicalNamingStrategy() .toPhysicalTableName( logicalIdentifier, getBuildingContext().getMetadataCollector().getDatabase().getJdbcEnvironment()); setExplicitTableName( physicalIdentifier.render( getBuildingContext().getMetadataCollector().getDatabase().getDialect())); } } }
public void linkValueUsingDefaultColumnNaming( Column referencedColumn, PersistentClass referencedEntity, SimpleValue value) { String logicalReferencedColumn = getBuildingContext() .getMetadataCollector() .getLogicalColumnName(referencedEntity.getTable(), referencedColumn.getQuotedName()); String columnName = buildDefaultColumnName(referencedEntity, logicalReferencedColumn); // yuk side effect on an implicit column setLogicalColumnName(columnName); setReferencedColumn(logicalReferencedColumn); initMappingColumn( columnName, null, referencedColumn.getLength(), referencedColumn.getPrecision(), referencedColumn.getScale(), getMappingColumn() != null ? getMappingColumn().isNullable() : false, referencedColumn.getSqlType(), getMappingColumn() != null ? getMappingColumn().isUnique() : false, false); linkWithValue(value); }