HHH-18341 fix the issue simply by removing obsolete code
also take the opportunity to "do" a todo Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
5baf866f16
commit
8eb4d8da0d
|
@ -237,10 +237,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
public Column[] getOverriddenColumn(String propertyName) {
|
||||
final Column[] result = getExactOverriddenColumn( propertyName );
|
||||
if ( result == null ) {
|
||||
if ( propertyName.contains( ".collection&&element." ) ) {
|
||||
if ( propertyName.contains( ".{element}." ) ) {
|
||||
//support for non map collections where no prefix is needed
|
||||
//TODO cache the underlying regexp
|
||||
return getExactOverriddenColumn( propertyName.replace( ".collection&&element.", "." ) );
|
||||
return getExactOverriddenColumn( propertyName.replace( ".{element}.", "." ) );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -294,10 +294,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
@Override
|
||||
public JoinColumn[] getOverriddenJoinColumn(String propertyName) {
|
||||
final JoinColumn[] result = getExactOverriddenJoinColumn( propertyName );
|
||||
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
|
||||
if ( result == null && propertyName.contains( ".{element}." ) ) {
|
||||
//support for non map collections where no prefix is needed
|
||||
//TODO cache the underlying regexp
|
||||
return getExactOverriddenJoinColumn( propertyName.replace( ".collection&&element.", "." ) );
|
||||
return getExactOverriddenJoinColumn( propertyName.replace( ".{element}.", "." ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -325,10 +325,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
@Override
|
||||
public ForeignKey getOverriddenForeignKey(String propertyName) {
|
||||
final ForeignKey result = getExactOverriddenForeignKey( propertyName );
|
||||
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
|
||||
if ( result == null && propertyName.contains( ".{element}." ) ) {
|
||||
//support for non map collections where no prefix is needed
|
||||
//TODO cache the underlying regexp
|
||||
return getExactOverriddenForeignKey( propertyName.replace( ".collection&&element.", "." ) );
|
||||
return getExactOverriddenForeignKey( propertyName.replace( ".{element}.", "." ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -371,10 +371,10 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
|
|||
*/
|
||||
public JoinTable getOverriddenJoinTable(String propertyName) {
|
||||
final JoinTable result = getExactOverriddenJoinTable( propertyName );
|
||||
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
|
||||
if ( result == null && propertyName.contains( ".{element}." ) ) {
|
||||
//support for non map collections where no prefix is needed
|
||||
//TODO cache the underlying regexp
|
||||
return getExactOverriddenJoinTable( propertyName.replace( ".collection&&element.", "." ) );
|
||||
return getExactOverriddenJoinTable( propertyName.replace( ".{element}.", "." ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -400,9 +400,9 @@ public class AnnotatedColumn {
|
|||
);
|
||||
|
||||
// HHH-6005 magic
|
||||
if ( implicitName.getText().contains( "_collection&&element_" ) ) {
|
||||
if ( implicitName.getText().contains( "_{element}_" ) ) {
|
||||
implicitName = Identifier.toIdentifier(
|
||||
implicitName.getText().replace( "_collection&&element_", "_" ),
|
||||
implicitName.getText().replace( "_{element}_", "_" ),
|
||||
implicitName.isQuoted()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -445,9 +445,9 @@ public class AnnotatedJoinColumns extends AnnotatedColumns {
|
|||
new OwnedImplicitJoinColumnNameSource(referencedEntity, logicalTableName, logicalReferencedColumn)
|
||||
);
|
||||
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
|
||||
if ( columnIdentifier.getText().contains( "_collection&&element_" ) ) {
|
||||
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
|
||||
columnIdentifier = Identifier.toIdentifier(
|
||||
columnIdentifier.getText().replace( "_collection&&element_", "_" ),
|
||||
columnIdentifier.getText().replace( "_{element}_", "_" ),
|
||||
columnIdentifier.isQuoted()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2490,8 +2490,8 @@ public abstract class CollectionBinder {
|
|||
return new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass );
|
||||
}
|
||||
else {
|
||||
//"collection&&element" is not a valid property name => placeholder
|
||||
return new PropertyPreloadedData( AccessType.PROPERTY, "collection&&element", elementClass );
|
||||
//"{element}" is not a valid property name => placeholder
|
||||
return new PropertyPreloadedData( AccessType.PROPERTY, "{element}", elementClass );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,22 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.boot.model.source.spi;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAttributeKey {
|
||||
// todo : replace this with "{element}"
|
||||
private static final String COLLECTION_ELEMENT = "collection&&element";
|
||||
private static final String DOT_COLLECTION_ELEMENT = '.' + COLLECTION_ELEMENT;
|
||||
private static final Pattern DOT_COLLECTION_ELEMENT_PATTERN = Pattern.compile(
|
||||
DOT_COLLECTION_ELEMENT,
|
||||
Pattern.LITERAL
|
||||
);
|
||||
private static final String COLLECTION_ELEMENT = "{element}";
|
||||
|
||||
private final AbstractAttributeKey parent;
|
||||
private final String property;
|
||||
|
@ -125,26 +116,12 @@ public abstract class AbstractAttributeKey {
|
|||
* Does this part represent a collection-element reference?
|
||||
*
|
||||
* @return {@code true} if the current property is a collection element
|
||||
* marker ({@link #COLLECTION_ELEMENT}
|
||||
* marker {@value #COLLECTION_ELEMENT}
|
||||
*/
|
||||
public boolean isCollectionElement() {
|
||||
return COLLECTION_ELEMENT.equals( property );
|
||||
}
|
||||
|
||||
/**
|
||||
* Does any part represent a collection-element reference?
|
||||
*
|
||||
* @return {@code true} if this part or any parent part is a collection element
|
||||
* marker ({@link #COLLECTION_ELEMENT}.
|
||||
*/
|
||||
public boolean isPartOfCollectionElement() {
|
||||
return fullPath.contains( DOT_COLLECTION_ELEMENT );
|
||||
}
|
||||
|
||||
public String stripCollectionElementMarker() {
|
||||
return DOT_COLLECTION_ELEMENT_PATTERN.matcher( fullPath ).replaceAll( Matcher.quoteReplacement( "" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getFullPath();
|
||||
|
|
|
@ -21,7 +21,7 @@ public class AttributePathTest {
|
|||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10863")
|
||||
public void testCollectionElement() {
|
||||
AttributePath attributePath = AttributePath.parse( "items.collection&&element.name" );
|
||||
AttributePath attributePath = AttributePath.parse( "items.{element}.name" );
|
||||
|
||||
assertFalse( attributePath.isCollectionElement() );
|
||||
assertTrue( attributePath.getParent().isCollectionElement() );
|
||||
|
|
Loading…
Reference in New Issue