Skip to content

Commit 8eb4d8d

Browse files
committed
HHH-18341 fix the issue simply by removing obsolete code
also take the opportunity to "do" a todo Signed-off-by: Gavin King <[email protected]>
1 parent 5baf866 commit 8eb4d8d

File tree

6 files changed

+17
-40
lines changed

6 files changed

+17
-40
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AbstractPropertyHolder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ protected void setCurrentProperty(MemberDetails attributeMember) {
237237
public Column[] getOverriddenColumn(String propertyName) {
238238
final Column[] result = getExactOverriddenColumn( propertyName );
239239
if ( result == null ) {
240-
if ( propertyName.contains( ".collection&&element." ) ) {
240+
if ( propertyName.contains( ".{element}." ) ) {
241241
//support for non map collections where no prefix is needed
242242
//TODO cache the underlying regexp
243-
return getExactOverriddenColumn( propertyName.replace( ".collection&&element.", "." ) );
243+
return getExactOverriddenColumn( propertyName.replace( ".{element}.", "." ) );
244244
}
245245
}
246246
return result;
@@ -294,10 +294,10 @@ private Column[] getExactOverriddenColumn(String propertyName) {
294294
@Override
295295
public JoinColumn[] getOverriddenJoinColumn(String propertyName) {
296296
final JoinColumn[] result = getExactOverriddenJoinColumn( propertyName );
297-
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
297+
if ( result == null && propertyName.contains( ".{element}." ) ) {
298298
//support for non map collections where no prefix is needed
299299
//TODO cache the underlying regexp
300-
return getExactOverriddenJoinColumn( propertyName.replace( ".collection&&element.", "." ) );
300+
return getExactOverriddenJoinColumn( propertyName.replace( ".{element}.", "." ) );
301301
}
302302
return result;
303303
}
@@ -325,10 +325,10 @@ private JoinColumn[] getExactOverriddenJoinColumn(String propertyName) {
325325
@Override
326326
public ForeignKey getOverriddenForeignKey(String propertyName) {
327327
final ForeignKey result = getExactOverriddenForeignKey( propertyName );
328-
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
328+
if ( result == null && propertyName.contains( ".{element}." ) ) {
329329
//support for non map collections where no prefix is needed
330330
//TODO cache the underlying regexp
331-
return getExactOverriddenForeignKey( propertyName.replace( ".collection&&element.", "." ) );
331+
return getExactOverriddenForeignKey( propertyName.replace( ".{element}.", "." ) );
332332
}
333333
return result;
334334
}
@@ -371,10 +371,10 @@ public JoinTable getJoinTable(MemberDetails attributeMember) {
371371
*/
372372
public JoinTable getOverriddenJoinTable(String propertyName) {
373373
final JoinTable result = getExactOverriddenJoinTable( propertyName );
374-
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
374+
if ( result == null && propertyName.contains( ".{element}." ) ) {
375375
//support for non map collections where no prefix is needed
376376
//TODO cache the underlying regexp
377-
return getExactOverriddenJoinTable( propertyName.replace( ".collection&&element.", "." ) );
377+
return getExactOverriddenJoinTable( propertyName.replace( ".{element}.", "." ) );
378378
}
379379
return result;
380380
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ public MetadataBuildingContext getBuildingContext() {
400400
);
401401

402402
// HHH-6005 magic
403-
if ( implicitName.getText().contains( "_collection&&element_" ) ) {
403+
if ( implicitName.getText().contains( "_{element}_" ) ) {
404404
implicitName = Identifier.toIdentifier(
405-
implicitName.getText().replace( "_collection&&element_", "_" ),
405+
implicitName.getText().replace( "_{element}_", "_" ),
406406
implicitName.isQuoted()
407407
);
408408
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumns.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,9 @@ else if ( isOwnerSide() ) {
445445
new OwnedImplicitJoinColumnNameSource(referencedEntity, logicalTableName, logicalReferencedColumn)
446446
);
447447
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
448-
if ( columnIdentifier.getText().contains( "_collection&&element_" ) ) {
448+
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
449449
columnIdentifier = Identifier.toIdentifier(
450-
columnIdentifier.getText().replace( "_collection&&element_", "_" ),
450+
columnIdentifier.getText().replace( "_{element}_", "_" ),
451451
columnIdentifier.isQuoted()
452452
);
453453
}

hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,8 +2490,8 @@ private PropertyData getSpecialMembers(TypeDetails elementClass) {
24902490
return new PropertyPreloadedData( AccessType.PROPERTY, "element", elementClass );
24912491
}
24922492
else {
2493-
//"collection&&element" is not a valid property name => placeholder
2494-
return new PropertyPreloadedData( AccessType.PROPERTY, "collection&&element", elementClass );
2493+
//"{element}" is not a valid property name => placeholder
2494+
return new PropertyPreloadedData( AccessType.PROPERTY, "{element}", elementClass );
24952495
}
24962496
}
24972497
}

hibernate-core/src/main/java/org/hibernate/boot/model/source/spi/AbstractAttributeKey.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,13 @@
66
*/
77
package org.hibernate.boot.model.source.spi;
88

9-
import java.util.regex.Matcher;
10-
import java.util.regex.Pattern;
11-
129
import org.hibernate.internal.util.StringHelper;
1310

1411
/**
1512
* @author Steve Ebersole
1613
*/
1714
public abstract class AbstractAttributeKey {
18-
// todo : replace this with "{element}"
19-
private static final String COLLECTION_ELEMENT = "collection&&element";
20-
private static final String DOT_COLLECTION_ELEMENT = '.' + COLLECTION_ELEMENT;
21-
private static final Pattern DOT_COLLECTION_ELEMENT_PATTERN = Pattern.compile(
22-
DOT_COLLECTION_ELEMENT,
23-
Pattern.LITERAL
24-
);
15+
private static final String COLLECTION_ELEMENT = "{element}";
2516

2617
private final AbstractAttributeKey parent;
2718
private final String property;
@@ -125,26 +116,12 @@ public boolean isRoot() {
125116
* Does this part represent a collection-element reference?
126117
*
127118
* @return {@code true} if the current property is a collection element
128-
* marker ({@link #COLLECTION_ELEMENT}
119+
* marker {@value #COLLECTION_ELEMENT}
129120
*/
130121
public boolean isCollectionElement() {
131122
return COLLECTION_ELEMENT.equals( property );
132123
}
133124

134-
/**
135-
* Does any part represent a collection-element reference?
136-
*
137-
* @return {@code true} if this part or any parent part is a collection element
138-
* marker ({@link #COLLECTION_ELEMENT}.
139-
*/
140-
public boolean isPartOfCollectionElement() {
141-
return fullPath.contains( DOT_COLLECTION_ELEMENT );
142-
}
143-
144-
public String stripCollectionElementMarker() {
145-
return DOT_COLLECTION_ELEMENT_PATTERN.matcher( fullPath ).replaceAll( Matcher.quoteReplacement( "" ) );
146-
}
147-
148125
@Override
149126
public String toString() {
150127
return getFullPath();

hibernate-core/src/test/java/org/hibernate/orm/test/boot/model/source/AttributePathTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AttributePathTest {
2121
@Test
2222
@TestForIssue(jiraKey = "HHH-10863")
2323
public void testCollectionElement() {
24-
AttributePath attributePath = AttributePath.parse( "items.collection&&element.name" );
24+
AttributePath attributePath = AttributePath.parse( "items.{element}.name" );
2525

2626
assertFalse( attributePath.isCollectionElement() );
2727
assertTrue( attributePath.getParent().isCollectionElement() );

0 commit comments

Comments
 (0)