-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
VirtualIdEmbeddable
and IdClassEmbeddable
+ instantiators
- Clean up Component Type, removing as many calls to its tuplizer as possible atm - Clean up ManagedMappingType, EntityPersister, etc - mainly work around getting and setting value(s) Still need to - integrate embedded forms. `VirtualIdEmbeddable` does not really need it as it can use the id-mapping itself as the embedded form. But `IdClassEmbedded` should really be integrated - integrate `VirtualKeyEmbeddable` and `VirtualKeyEmbedded` for use as inverse composite fks - share `#finishInit` handling for `EmbeddableMappingType`, `VirtualIdEmbeddable` and `IdClassEmbeddable` - ability to use the containing composite owner as the parent of a composite (legacy behavior is to always use the "first" entity - clean up ComponentType, esp wrt its use of ComponentTuplizer
- Loading branch information
Showing
45 changed files
with
228 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ore/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEmbeddableMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html | ||
*/ | ||
package org.hibernate.metamodel.mapping.internal; | ||
|
||
import org.hibernate.bytecode.spi.ReflectionOptimizer; | ||
import org.hibernate.engine.spi.SessionFactoryImplementor; | ||
import org.hibernate.metamodel.mapping.EmbeddableMappingType; | ||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; | ||
import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl; | ||
import org.hibernate.property.access.spi.Getter; | ||
import org.hibernate.type.descriptor.java.JavaType; | ||
|
||
/** | ||
* Base support for EmbeddableMappingType implementations | ||
*/ | ||
public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType { | ||
protected final SessionFactoryImplementor sessionFactory; | ||
|
||
public AbstractEmbeddableMapping(MappingModelCreationProcess creationProcess) { | ||
this( creationProcess.getCreationContext() ); | ||
} | ||
|
||
public AbstractEmbeddableMapping(RuntimeModelCreationContext creationContext) { | ||
this( creationContext.getSessionFactory() ); | ||
} | ||
|
||
protected AbstractEmbeddableMapping(SessionFactoryImplementor sessionFactory) { | ||
this.sessionFactory = sessionFactory; | ||
} | ||
|
||
@Override | ||
public JavaType<?> getMappedJavaTypeDescriptor() { | ||
return getRepresentationStrategy().getMappedJavaTypeDescriptor(); | ||
} | ||
|
||
@Override | ||
public Object[] getValues(Object compositeInstance) { | ||
if ( compositeInstance == PropertyAccessStrategyBackRefImpl.UNKNOWN ) { | ||
return new Object[getNumberOfAttributeMappings()]; | ||
} | ||
|
||
final ReflectionOptimizer optimizer = getRepresentationStrategy().getReflectionOptimizer(); | ||
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) { | ||
return optimizer.getAccessOptimizer().getPropertyValues( compositeInstance ); | ||
} | ||
|
||
final Object[] results = new Object[getNumberOfAttributeMappings()]; | ||
forEachAttributeMapping( (position, attribute) -> { | ||
final Getter getter = attribute.getAttributeMetadataAccess() | ||
.resolveAttributeMetadata( null ) | ||
.getPropertyAccess() | ||
.getGetter(); | ||
results[position] = getter.get( compositeInstance ); | ||
} ); | ||
return results; | ||
} | ||
|
||
@Override | ||
public void setValues(Object component, Object[] values) { | ||
final ReflectionOptimizer optimizer = getRepresentationStrategy().getReflectionOptimizer(); | ||
if ( optimizer != null && optimizer.getAccessOptimizer() != null ) { | ||
optimizer.getAccessOptimizer().setPropertyValues( component, values ); | ||
} | ||
else { | ||
forEachAttributeMapping( (position, attribute) -> { | ||
attribute.getPropertyAccess().getSetter().set( component, values[position] ); | ||
} ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.