Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import jakarta.persistence.CollectionTable;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Used to override the collection table configuration for a collection
* that is nested within an embeddable class.
*
* <p>This annotation allows overriding the collection table configuration
* for collections that are defined within an embeddable class.
*
* <p>Example:
* <pre>
* &#064;Embeddable
* public class Address {
* &#064;ElementCollection
* &#064;CollectionTable(name = "default_phones")
* List&lt;Phone&gt; phones;
* }
*
* &#064;Entity
* public class Person {
* &#064;Embedded
* &#064;CollectionTableOverride(
* name = "phones",
* collectionTable = &#064;CollectionTable(name = "person_phones")
* )
* Address address;
* }
* </pre>
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
public @interface CollectionTableOverride {
/**
* The path to the collection property within the embeddable.
* For example, if the embeddable has a field "phones", the name would be "phones".
* For nested embeddables, use dot notation like "address.phones".
*/
String name();

/**
* The collection table configuration to use instead of the default.
* This allows specifying the full {@link CollectionTable} annotation
* with all its attributes (name, schema, catalog, joinColumns, indexes, etc.).
*/
CollectionTable collectionTable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Container for multiple {@link CollectionTableOverride} annotations.
*/
@Target({ TYPE, METHOD, FIELD })
@Retention(RUNTIME)
public @interface CollectionTableOverrides {
CollectionTableOverride[] value();
}
Loading