Skip to content

Commit

Permalink
HHH-12684 - Hibernate fails when mapping one-to-many collections by n…
Browse files Browse the repository at this point in the history
…on-primary key

Fix indentation issues
  • Loading branch information
vladmihalcea committed Jun 26, 2018
1 parent 7ead344 commit 84439af
Showing 1 changed file with 15 additions and 15 deletions.
Expand Up @@ -72,35 +72,35 @@ protected AbstractPluralAttributeSourceImpl(

Optional<JaxbHbmManyToOneType> jaxbHbmManyToOneTypeOptional = Optional.empty();

if(pluralAttributeJaxbMapping.isInverse() && pluralAttributeJaxbMapping.getOneToMany() != null) {
if ( pluralAttributeJaxbMapping.isInverse() && pluralAttributeJaxbMapping.getOneToMany() != null ) {
String childClass = pluralAttributeJaxbMapping.getOneToMany().getClazz();

if ( childClass != null ) {
jaxbHbmManyToOneTypeOptional = mappingDocument.getDocumentRoot().getClazz()
.stream()
.filter( (JaxbHbmRootEntityType entityType) ->
childClass.equals( entityType.getName() ) )
childClass.equals( entityType.getName() ) )
.flatMap( jaxbHbmRootEntityType -> jaxbHbmRootEntityType.getAttributes().stream() )
.filter(
attribute -> attribute instanceof JaxbHbmManyToOneType &&
((JaxbHbmManyToOneType) attribute).getPropertyRef() != null )
( (JaxbHbmManyToOneType) attribute ).getPropertyRef() != null )
.map( JaxbHbmManyToOneType.class::cast )
.findFirst();
}
}

this.keySource = jaxbHbmManyToOneTypeOptional
.map( jaxbHbmManyToOneType -> new PluralAttributeKeySourceImpl(
sourceMappingDocument(),
jaxbHbmManyToOneType,
container
) ).orElseGet( () -> new PluralAttributeKeySourceImpl(
sourceMappingDocument(),
pluralAttributeJaxbMapping.isInverse() ?
pluralAttributeJaxbMapping.getKey() :
pluralAttributeJaxbMapping.getKey(),
container
) );
.map( jaxbHbmManyToOneType -> new PluralAttributeKeySourceImpl(
sourceMappingDocument(),
jaxbHbmManyToOneType,
container
) ).orElseGet( () -> new PluralAttributeKeySourceImpl(
sourceMappingDocument(),
pluralAttributeJaxbMapping.isInverse() ?
pluralAttributeJaxbMapping.getKey() :
pluralAttributeJaxbMapping.getKey(),
container
) );

this.typeInformation = new HibernateTypeSourceImpl( pluralAttributeJaxbMapping.getCollectionType() );

Expand Down Expand Up @@ -129,7 +129,7 @@ private static String[] extractSynchronizedTableNames(PluralAttributeInfo plural
return new String[0];
}

final String[] names = new String[ pluralAttributeElement.getSynchronize().size() ];
final String[] names = new String[pluralAttributeElement.getSynchronize().size()];
int i = 0;
for ( JaxbHbmSynchronizeType jaxbHbmSynchronizeType : pluralAttributeElement.getSynchronize() ) {
names[i++] = jaxbHbmSynchronizeType.getTable();
Expand Down

0 comments on commit 84439af

Please sign in to comment.