-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19257 - Introduce @EmbeddedTable #11059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
hibernate-core/src/main/java/org/hibernate/annotations/EmbeddedTable.java
This file contains hidden or 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,49 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.annotations; | ||
|
||
import org.hibernate.Incubating; | ||
|
||
import java.lang.annotation.Target; | ||
import java.lang.annotation.Retention; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
import static java.lang.annotation.ElementType.METHOD; | ||
import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
||
/** | ||
* An easier mechanism to declare the table to which an embedded value | ||
* maps compared to the Jakarta Persistence compliant mechanism requiring | ||
* multiple {@link jakarta.persistence.AttributeOverride} | ||
* and {@link jakarta.persistence.AssociationOverride} annotations. | ||
* <pre> | ||
* @Entity | ||
* @Table(name="primary") | ||
* @SecondaryTable(name="secondary") | ||
* class Person { | ||
* ... | ||
* @Embedded | ||
* @EmbeddedTable("secondary") | ||
* Address address; | ||
* } | ||
* </pre> | ||
* | ||
* @apiNote Only supported for an embedded declared on an entity or mapped-superclass; all other (mis)uses | ||
* will lead to a {@linkplain org.hibernate.boot.models.AnnotationPlacementException}. | ||
* | ||
* @see EmbeddedColumnNaming | ||
* | ||
* @since 7.2 | ||
* @author Steve Ebersole | ||
*/ | ||
@Target({METHOD, FIELD}) | ||
@Retention(RUNTIME) | ||
@Incubating | ||
public @interface EmbeddedTable { | ||
/** | ||
* The name of the table in which the embedded value is stored. | ||
*/ | ||
String value(); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
57 changes: 57 additions & 0 deletions
57
...src/main/java/org/hibernate/boot/models/annotations/internal/EmbeddedTableAnnotation.java
This file contains hidden or 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,57 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate.boot.models.annotations.internal; | ||
|
||
import org.hibernate.annotations.EmbeddedTable; | ||
import org.hibernate.models.spi.ModelsContext; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Steve Ebersole | ||
*/ | ||
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" }) | ||
public class EmbeddedTableAnnotation implements EmbeddedTable { | ||
private String value; | ||
|
||
/** | ||
* Used in creating dynamic annotation instances (e.g. from XML) | ||
*/ | ||
public EmbeddedTableAnnotation(ModelsContext modelContext) { | ||
} | ||
|
||
/** | ||
* Used in creating annotation instances from JDK variant | ||
*/ | ||
public EmbeddedTableAnnotation( | ||
EmbeddedTable annotation, | ||
ModelsContext modelContext) { | ||
|
||
this.value = annotation.value(); | ||
} | ||
|
||
/** | ||
* Used in creating annotation instances from Jandex variant | ||
*/ | ||
public EmbeddedTableAnnotation( | ||
Map<String, Object> attributeValues, | ||
ModelsContext modelContext) { | ||
|
||
this.value = (String) attributeValues.get( "value" ); | ||
} | ||
|
||
@Override | ||
public Class<? extends Annotation> annotationType() { | ||
return EmbeddedTable.class; | ||
} | ||
|
||
@Override | ||
public String value() { | ||
return value; | ||
} | ||
|
||
public void value(String value) { | ||
this.value = value; | ||
} | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.