-
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
Prep work for EmbeddableInstantiator - initializer Still need to - integrate EmbeddableInstantiator work - 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
- Loading branch information
Showing
3 changed files
with
112 additions
and
55 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...te-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableInstantiatorProxied.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,41 @@ | ||
/* | ||
* 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.internal; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.hibernate.bytecode.spi.BasicProxyFactory; | ||
import org.hibernate.engine.spi.SessionFactoryImplementor; | ||
import org.hibernate.metamodel.spi.EmbeddableInstantiator; | ||
|
||
/** | ||
* EmbeddableInstantiator used for instantiating "proxies" of an embeddable. | ||
*/ | ||
public class EmbeddableInstantiatorProxied implements EmbeddableInstantiator { | ||
private final Class<?> proxiedClass; | ||
private final BasicProxyFactory factory; | ||
|
||
public EmbeddableInstantiatorProxied(Class proxiedClass, BasicProxyFactory factory) { | ||
this.proxiedClass = proxiedClass; | ||
this.factory = factory; | ||
} | ||
|
||
@Override | ||
public Object instantiate(Supplier<Object[]> valuesAccess, SessionFactoryImplementor sessionFactory) { | ||
return factory.getProxy(); | ||
} | ||
|
||
@Override | ||
public boolean isInstance(Object object, SessionFactoryImplementor sessionFactory) { | ||
return proxiedClass.isInstance( object ); | ||
} | ||
|
||
@Override | ||
public boolean isSameClass(Object object, SessionFactoryImplementor sessionFactory) { | ||
return object.getClass() == proxiedClass; | ||
} | ||
} |
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