Skip to content

Commit 6fb622c

Browse files
committed
HHH-19324 - Switch tests using hbm.xml to use mapping.xml
HHH-19310 - Simplified declaration of type for basic mappings in XML HHH-19422 - Introduce @CollectionIdJavaClass
1 parent 3c144ab commit 6fb622c

File tree

251 files changed

+4020
-7184
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+4020
-7184
lines changed

documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[[collections]]
22
=== Collections
3-
:majorMinorVersion: 6.2
43
:root-project-dir: ../../../../../../..
54
:core-project-dir: {root-project-dir}/hibernate-core
65
:core-test-base: {core-project-dir}/src/test/java
76
:example-dir-collection: {core-test-base}/org/hibernate/orm/test/mapping/collections
87
:docs-base: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}
9-
:javadoc-base: {docs-base}/javadoc
8+
:javadoc-base: {docs-base}/javadocs
109
:java-javadoc-base: https://docs.oracle.com/en/java/javase/11/docs/api/java.base
1110
:extrasdir: extras/collections
1211

@@ -285,7 +284,16 @@ is available to have Hibernate interpret a `List` with no `@OrderColumn` and no
285284

286285

287286
An ID_BAG is similar to a BAG, except that it maps a generated, per-row identifier into the collection
288-
table. `@CollectionId` is the annotation to configure this identifier
287+
table. `@CollectionId` is the annotation to configure this identifier.
288+
289+
For details about defining an id-bad identifier, see the Javadocs for:
290+
291+
* link:{javadoc-base}/org/hibernate/annotations/CollectionId.html[@CollectionId]
292+
* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJavaClass.html[@CollectionIdJavaClass]
293+
* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJavaType.html[@CollectionIdJavaType]
294+
* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJdbcType.html[@CollectionIdJdbcType]
295+
* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJdbcTypeCode.html[@CollectionIdJdbcTypeCode]
296+
* link:{javadoc-base}/org/hibernate/annotations/CollectionIdType.html[@CollectionIdType]
289297

290298

291299
// todo (6.0) - finish

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
import static org.hamcrest.MatcherAssert.assertThat;
2424
import static org.junit.jupiter.api.Assertions.assertNotNull;
2525

26-
@DomainModel(
27-
annotatedClasses = { Person.class },
28-
xmlMappings = "org/hibernate/community/dialect/Person.hbm.xml"
29-
)
26+
@DomainModel(annotatedClasses = Person.class)
3027
@RequiresDialect(AltibaseDialect.class)
3128
@SessionFactory
3229
public class AltibaseFunctionsTest {

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/Person.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,20 @@
44
*/
55
package org.hibernate.community.dialect;
66

7-
import java.sql.*;
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.GeneratedValue;
9+
import jakarta.persistence.Id;
10+
import jakarta.persistence.SequenceGenerator;
811

12+
import java.sql.Date;
13+
import java.sql.Blob;
14+
import java.sql.Clob;
15+
16+
@Entity
917
public class Person {
18+
@Id
19+
@GeneratedValue
20+
@SequenceGenerator(sequenceName = "PERSON_SEQ")
1021
private int id;
1122
private String name;
1223
private Date birthDate;

hibernate-community-dialects/src/test/resources/org/hibernate/community/dialect/Person.hbm.xml

Lines changed: 0 additions & 25 deletions
This file was deleted.

hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
import static java.lang.annotation.RetentionPolicy.RUNTIME;
1717

1818
/**
19-
* Describe an identifier column for a bag.
19+
* Describe the identifier for an id-bag.
20+
*
21+
* @see CollectionIdJavaClass
22+
* @see CollectionIdJavaType
23+
* @see CollectionIdJdbcType
24+
* @see CollectionIdJdbcTypeCode
25+
* @see CollectionIdMutability
26+
* @see CollectionIdType
2027
*
2128
* @author Emmanuel Bernard
2229
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
* Copyright Red Hat Inc. and Hibernate Authors
4+
*/
5+
package org.hibernate.annotations;
6+
7+
import org.hibernate.Incubating;
8+
9+
import java.lang.annotation.Retention;
10+
import java.lang.annotation.Target;
11+
12+
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
13+
import static java.lang.annotation.ElementType.FIELD;
14+
import static java.lang.annotation.ElementType.METHOD;
15+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
16+
17+
/**
18+
* Specifies the Java class to use for the {@linkplain CollectionId id} of an id-bag mapping.
19+
* An alternative to {@linkplain CollectionIdJavaType}. E.g.
20+
*
21+
* <pre>
22+
* &#64;Bag
23+
* &#64;CollectionId(generator="increment")
24+
* &#64;CollectionIdJavaClass(Integer.class)
25+
* Collection&lt;Person&gt; authors;
26+
* </pre>
27+
*
28+
* @since 7.1
29+
*
30+
* @author Steve Ebersole
31+
*/
32+
@Incubating
33+
@Target({METHOD, FIELD, ANNOTATION_TYPE})
34+
@Retention(RUNTIME)
35+
public @interface CollectionIdJavaClass {
36+
/**
37+
* The Java class to use as the collection-id.
38+
*/
39+
Class<?> idType();
40+
}

hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaType.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
/**
1919
* Form of {@link JavaType} for describing the id of an id-bag mapping.
2020
*
21+
* @see CollectionIdJavaClass
22+
*
2123
* @since 6.0
2224
*/
2325
@Inherited

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbAnyMapping.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55
package org.hibernate.boot.jaxb.mapping.spi;
66

7+
import jakarta.persistence.DiscriminatorType;
8+
79
import java.util.List;
810

911
/**
@@ -29,6 +31,8 @@ public interface JaxbAnyMapping extends JaxbPersistentAttribute {
2931
*/
3032
interface Key {
3133
List<JaxbColumnImpl> getColumns();
34+
String getType();
35+
String getJavaClass();
3236
}
3337

3438
/**
@@ -42,6 +46,11 @@ interface Discriminator {
4246
*/
4347
JaxbColumnImpl getColumn();
4448

49+
/**
50+
* The type of discriminator
51+
*/
52+
DiscriminatorType getType();
53+
4554
/**
4655
* Mapping of discriminator-values to the corresponding entity names
4756
*/

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
* @author Steve Ebersole
1212
*/
1313
public interface JaxbBasicMapping {
14+
/**
15+
* The attribute's name
16+
*/
17+
String getName();
18+
void setName(String name);
19+
1420
JaxbUserTypeImpl getType();
1521

1622
void setType(JaxbUserTypeImpl value);

hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
*/
55
package org.hibernate.boot.jaxb.mapping.spi;
66

7+
import org.checkerframework.checker.nullness.qual.Nullable;
8+
79
/**
810
* @author Steve Ebersole
911
*/
1012
public interface JaxbEmbeddable extends JaxbManagedType {
13+
@Nullable
14+
String getName();
15+
void setName(@Nullable String name);
1116
}

0 commit comments

Comments
 (0)