/** * For JPA standards we typically need the unqualified name. However, a more usable * impl tends to use the whole path. This method provides an easy hook for subclasses * to accomplish that * * @param attributePath The attribute path * * @return The extracted name */ protected String transformAttributePath(AttributePath attributePath) { return attributePath.getProperty(); }
public static void process(AttributePath attributePath, StringBuilder sb) { if ( attributePath.getParent() != null ) { process( attributePath.getParent(), sb ); if ( !"".equals( attributePath.getParent().getProperty() ) ) { sb.append( "_" ); } } String property = attributePath.getProperty(); property = property.replace( "<", "" ); property = property.replace( ">", "" ); sb.append( property ); } }
public static AttributePath parse(String path) { if ( path == null ) { return null; } AttributePath attributePath = new AttributePath(); for ( String part : path.split( "\\." ) ) { attributePath = attributePath.append( part ); } return attributePath; } }
String property = path.getProperty(); String columnName = source.getReferencedColumnName().getText(); if (path.getDepth() == 1) { String name; if (property.endsWith("target") && "oid".equals(columnName)) { } else { if ("ownerRefCampaign.target".equals(path.getFullPath()) || "ownerRefDefinition.target".equals(path.getFullPath()) || "ownerRefTask.target".equals(path.getFullPath())) { path = AttributePath.parse("ownerRef.target"); AttributePath parent = path.getParent(); String translatedParent = transformAttributePath(parent);
private String componentPath(AttributePath attributePath) { AttributePath parentAttributePath = attributePath; StringBuilder builder = new StringBuilder( parentAttributePath.getProperty() ); while ( !attributePath.getParent().isCollectionElement() ) { attributePath = attributePath.getParent(); builder.insert( 0, "." ); builder.insert( 0, attributePath.getProperty() ); } String componentPath = builder.toString(); return componentPath; } }
@Override public AttributePath getAttributePathBase() { return pluralAttributeSource.getAttributePath().append( "key" ); }
elementBinding, null, embeddableSource.getAttributePathBase().getProperty(), getPluralAttributeSource().getXmlNodeName(), false elementBinding, getPluralAttributeSource().getAttributeRole().append( "element" ), getPluralAttributeSource().getAttributePath().append( "element" )
@Override public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) { String columnName = source.getAttributePath().getProperty(); String fullPath = source.getAttributePath().getFullPath(); String result; if (fullPath.startsWith("credentials.") || fullPath.startsWith("activation.")) { //credentials and activation are embedded and doesn't need to be qualified return super.determineBasicColumnName(source); } else { if (fullPath.contains("&&")) { // it's collection result = columnName; } else { result = fullPath.replaceAll("\\.", "_"); } } result = RUtil.fixDBSchemaObjectNameLength(result); Identifier i = toIdentifier(result, source.getBuildingContext()); LOGGER.trace("determineBasicColumnName {} {}", fullPath, i); return i; } }
@Override public AttributePath getOwningAttributePath() { // we don't know path on the annotations side :( return AttributePath.parse( propertyName ); }
@Override public AttributePath append(String property) { return new AttributePath( this, property ); }
/** * Generates a name for a table column. */ @Override public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) { AttributePath attributePath = source.getAttributePath(); String propertyName = getPropertyName(attributePath); String parentPropertyName = getPropertyName(attributePath.getParent()); Ejb3Column column = getEjb3Column(source); // generate a name for an embedded column if (isEmbedded(column)) { String fluentNamePrefix = getFluentNamePrefix(column, parentPropertyName); boolean hasEmbeddedPrefix = !InternalUtils.StringUtils.isEmpty(fluentNamePrefix); String prefix = hasEmbeddedPrefix ? fluentNamePrefix : parentPropertyName; boolean dontTouchPrefix = hasEmbeddedPrefix; return toIdentifier( strategy.embeddedPropertyToColumnName(prefix, propertyName, dontTouchPrefix), source); } // It is a strange behaviour for collection associations. // For an example for a "roles" association Hibernate uses "roles.element". if (!InternalUtils.StringUtils.isEmpty(parentPropertyName) && propertyName.equals("element")) { return toIdentifier(propertyName, source); } // Hibernate calls this method the first time for @Embedded column, but doesn't use a result return toIdentifier(strategy.propertyToColumnName(propertyName), source); }
@Override protected String transformAttributePath(AttributePath attributePath) { if ( attributePath.isPartOfCollectionElement() ) { return componentPath( attributePath ); } return attributePath.getFullPath(); }
@Override public AttributePath getAttributePathBase() { return pluralAttributeSource.getAttributePath().append( "element" ); }
@Override public AttributePath getAssociationOwningAttributePath() { return AttributePath.parse( propertyName ); }
protected AbstractEntitySourceImpl(MappingDocument sourceMappingDocument, JaxbHbmEntityBaseDefinition jaxbEntityMapping) { super( sourceMappingDocument ); this.jaxbEntityMapping = jaxbEntityMapping; this.entityNamingSource = extractEntityNamingSource( sourceMappingDocument, jaxbEntityMapping ); this.attributePathBase = new AttributePath(); this.attributeRoleBase = new AttributeRole( entityNamingSource.getEntityName() ); this.tuplizerClassMap = extractTuplizers( jaxbEntityMapping ); this.filterSources = buildFilterSources(); for ( JaxbHbmFetchProfileType jaxbFetchProfile : jaxbEntityMapping.getFetchProfile() ) { FetchProfileBinder.processFetchProfile( sourceMappingDocument, jaxbFetchProfile, entityNamingSource.getClassName() != null ? entityNamingSource.getClassName() : entityNamingSource.getEntityName() ); } this.toolingHintContext = Helper.collectToolingHints( sourceMappingDocument.getToolingHintContext(), jaxbEntityMapping ); }
@Override public Identifier determineJoinTableName(ImplicitJoinTableNameSource source) { String name = source.getOwningPhysicalTableName() + "_" + source.getAssociationOwningAttributePath().getProperty(); return toIdentifier(name, source.getBuildingContext()); }
public static void process(AttributePath attributePath, StringBuilder sb) { if ( attributePath.getParent() != null ) { process( attributePath.getParent(), sb ); if ( !"".equals( attributePath.getParent().getProperty() ) ) { sb.append( "_" ); } } String property = attributePath.getProperty(); property = property.replace( "<", "" ); property = property.replace( ">", "" ); sb.append( property ); } }
this.rootEntitySource = rootEntitySource; this.sourceMappingDocument = sourceMappingDocument; this.attributePathBase = rootEntitySource.getAttributePathBase().append( "<IdClass>" ); this.attributeRoleBase = rootEntitySource.getAttributeRoleBase().append( "<IdClass>" );
public static AttributePath parse(String path) { if ( path == null ) { return null; } AttributePath attributePath = new AttributePath(); for ( String part : path.split( "\\." ) ) { attributePath = attributePath.append( part ); } return attributePath; } }
@Override public AttributePath getAttributePath() { return AttributePath.parse( propertyName ); }