List of usage examples for org.hibernate.boot.model.source.spi AttributePath getProperty
public String getProperty()
From source file:com.evolveum.midpoint.repo.sql.util.MidPointImplicitNamingStrategy.java
License:Apache License
@Override public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) { Identifier i = super.determineJoinColumnName(source); // RObject, creatorRef.target, oid -> m_object.creatorRef_targetOid // RObjectReference, owner, oid -> m_object_reference.owner_oid // RObjectReference, target, oid -> m_object_reference.targetOid AttributePath path = source.getAttributePath(); String property = path.getProperty(); String columnName = source.getReferencedColumnName().getText(); Identifier real;// w ww . java 2s . c o m if (path.getDepth() == 1) { String name; if (property.endsWith("target") && "oid".equals(columnName)) { name = property + "Oid"; } else { name = StringUtils.join(Arrays.asList(property, columnName), "_"); } real = toIdentifier(name, source.getBuildingContext()); } else { // TODO fixme BRUTAL HACK -- we are not able to eliminate columns like 'ownerRefCampaign_targetOid' from the schema (even with @AttributeOverride/@AssociationOverride) 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); columnName = property + StringUtils.capitalize(columnName); real = toIdentifier(StringUtils.join(Arrays.asList(translatedParent, columnName), "_"), source.getBuildingContext()); } LOGGER.trace("determineJoinColumnName {} {} -> {}, {}", source.getReferencedTableName(), source.getReferencedColumnName(), i, real); return real; }
From source file:org.ligoj.bootstrap.core.dao.ImplicitNamingStrategyNiceJpaImpl.java
License:MIT License
/** * 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/*from w w w . j a v a 2s. c om*/ * * @param attributePath * The attribute path * @return The extracted name */ @Override protected String transformAttributePath(final AttributePath attributePath) { return StringUtils.lowerCase( StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(attributePath.getProperty()), '_')); }