@Override public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) { if ( source.getAttributePath() != null ) { return toIdentifier( transformAttributePath( source.getAttributePath() ), source.getBuildingContext() ); } return super.determineJoinColumnName( source ); }
@Override public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) { return source.isCollectionElement() ? toIdentifier( "elt", source.getBuildingContext() ) : super.determineBasicColumnName( source ); }
@Override public Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source) { Identifier identifier = toIdentifier( source.getOwningPhysicalTableName().getText() + "_" + transformAttributePath( source.getOwningAttributePath() ), source.getBuildingContext() ); if ( source.getOwningPhysicalTableName().isQuoted() ) { identifier = Identifier.quote( identifier ); } return identifier; }
public static Identifier quote(Identifier identifier) { return identifier.isQuoted() ? identifier : Identifier.toIdentifier( identifier.getText(), true ); }
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { return Identifier.toIdentifier( "TAB_" + name.getText() ); } }
@Override public Identifier determineJoinTableName(ImplicitJoinTableNameSource source) { if ( source.getAssociationOwningAttributePath() != null ) { final String name = source.getOwningPhysicalTableName() + '_' + transformAttributePath( source.getAssociationOwningAttributePath() ); return toIdentifier( name, source.getBuildingContext() ); } return super.determineJoinTableName( source ); } }
@Override public Identifier determineJoinTableName(ImplicitJoinTableNameSource source) { final String ownerPortion = source.getOwningPhysicalTableName(); final String ownedPortion; if ( source.getNonOwningPhysicalTableName() != null ) { ownedPortion = source.getNonOwningPhysicalTableName(); } else { ownedPortion = transformAttributePath( source.getAssociationOwningAttributePath() ); } return toIdentifier( ownerPortion + "_" + ownedPortion, source.getBuildingContext() ); }
@Override public Identifier determineCollectionTableName(ImplicitCollectionTableNameSource source) { // JPA states we should use the following as default: // "The concatenation of the name of the containing entity and the name of the // collection attribute, separated by an underscore. // aka: // if owning entity has a JPA entity name: {OWNER JPA ENTITY NAME}_{COLLECTION ATTRIBUTE NAME} // otherwise: {OWNER ENTITY NAME}_{COLLECTION ATTRIBUTE NAME} final String entityName = transformEntityName( source.getOwningEntityNaming() ); final String name = entityName + '_' + transformAttributePath( source.getOwningAttributePath() ); return toIdentifier( name, source.getBuildingContext() ); }
@Override public Identifier determineJoinTableName(ImplicitJoinTableNameSource source) { // JPA states we should use the following as default: // "The concatenated names of the two associated primary entity tables (owning side // first), separated by an underscore." // aka: // {OWNING SIDE PRIMARY TABLE NAME}_{NON-OWNING SIDE PRIMARY TABLE NAME} final String name = source.getOwningPhysicalTableName() + '_' + source.getNonOwningPhysicalTableName(); return toIdentifier( name, source.getBuildingContext() ); }
@Override public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) { // JPA states we should use the following as default: // "The property or field name" // aka: // The unqualified attribute path. return toIdentifier( transformAttributePath( source.getAttributePath() ), source.getBuildingContext() ); }
@Override public Identifier getUserProvidedIdentifier() { return originalKeyName != null ? Identifier.toIdentifier( originalKeyName ) : null; } }
@Override public Identifier determineMapKeyColumnName(ImplicitMapKeyColumnNameSource source) { return toIdentifier( transformAttributePath( source.getPluralAttributePath() ) + "_KEY", source.getBuildingContext() ); }
@Override public Identifier determineListIndexColumnName(ImplicitIndexColumnNameSource source) { return toIdentifier( transformAttributePath( source.getPluralAttributePath() ) + "_ORDER", source.getBuildingContext() ); }
@Override public Identifier determineIdentifierColumnName(ImplicitIdentifierColumnNameSource source) { // JPA states the implicit column name should be the attribute name return toIdentifier( transformAttributePath( source.getIdentifierAttributePath() ), source.getBuildingContext() ); }
private static String extract(Identifier identifier) { if ( identifier == null ) { return null; } return identifier.render(); }
@Override public Identifier determinePrimaryKeyJoinColumnName(ImplicitPrimaryKeyJoinColumnNameSource source) { // JPA states we should use the following as default: // "the same name as the primary key column [of the referenced table]" return source.getReferencedPrimaryKeyColumnName(); }
@Override public Identifier determineImplicitName(LocalMetadataBuildingContext context) { return implicitNamingStrategy.determineBasicColumnName( versionAttributeSource ); } }
public static boolean areEqual(Identifier id1, Identifier id2) { if ( id1 == null ) { return id2 == null; } else { return id1.equals( id2 ); } }
private String extractName(Identifier identifier, Dialect dialect) { if ( identifier == null ) { return null; } return identifier.render( dialect ); } }
private static String render(Identifier identifier, Dialect dialect) { if ( identifier == null ) { return null; } return identifier.render( dialect ); }