File tree Expand file tree Collapse file tree 8 files changed +146
-1
lines changed
main/java/org/hibernate/boot/models/xml/internal/attr
java/org/hibernate/orm/test/boot/models/xml/bad
resources/mappings/models/bad Expand file tree Collapse file tree 8 files changed +146
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public static MutableMemberDetails processEmbeddedIdAttribute(
3434 AccessType classAccessType ,
3535 XmlDocumentContext xmlDocumentContext ) {
3636 final AccessType accessType = coalesce ( jaxbEmbeddedId .getAccess (), classAccessType );
37- final MutableMemberDetails memberDetails = XmlProcessingHelper .findAttributeMember (
37+ final MutableMemberDetails memberDetails = XmlProcessingHelper .getAttributeMember (
3838 jaxbEmbeddedId .getName (),
3939 accessType ,
4040 classDetails
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .boot .models .xml .bad ;
6+
7+ import org .hibernate .boot .MetadataSources ;
8+ import org .hibernate .boot .models .MemberResolutionException ;
9+ import org .hibernate .testing .orm .junit .ServiceRegistry ;
10+ import org .hibernate .testing .orm .junit .ServiceRegistryScope ;
11+ import org .junit .jupiter .api .Test ;
12+
13+ import static org .junit .jupiter .api .Assertions .fail ;
14+
15+ /**
16+ * @author Steve Ebersole
17+ */
18+ public class BadMappingTests {
19+ @ Test
20+ @ ServiceRegistry
21+ void testBadEmbeddedName (ServiceRegistryScope registryScope ) {
22+ final MetadataSources metadataSources = new MetadataSources ( registryScope .getRegistry () )
23+ .addResource ( "mappings/models/bad/bad-embedded.xml" );
24+ try {
25+ metadataSources .buildMetadata ();
26+ fail ( "Expecting failure" );
27+ }
28+ catch (MemberResolutionException expected ){
29+ // expected outcome
30+ }
31+
32+ }
33+
34+ @ Test
35+ @ ServiceRegistry
36+ void testBadEmbeddedIdName (ServiceRegistryScope registryScope ) {
37+ final MetadataSources metadataSources = new MetadataSources ( registryScope .getRegistry () )
38+ .addResource ( "mappings/models/bad/bad-embedded-id.xml" );
39+ try {
40+ metadataSources .buildMetadata ();
41+ fail ( "Expecting failure" );
42+ }
43+ catch (MemberResolutionException expected ){
44+ // expected outcome
45+ }
46+ }
47+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .boot .models .xml .bad ;
6+
7+ /**
8+ * @author Steve Ebersole
9+ */
10+ public class Book {
11+ private Integer id ;
12+ private String name ;
13+ private Sku sku ;
14+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .boot .models .xml .bad ;
6+
7+ /**
8+ * @author Steve Ebersole
9+ */
10+ public class Product {
11+ private ProductKey id ;
12+ private String name ;
13+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .boot .models .xml .bad ;
6+
7+ /**
8+ * @author Steve Ebersole
9+ */
10+ public class ProductKey {
11+ private Integer companyId ;
12+ private String sku ;
13+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: Apache-2.0
3+ * Copyright Red Hat Inc. and Hibernate Authors
4+ */
5+ package org .hibernate .orm .test .boot .models .xml .bad ;
6+
7+ /**
8+ * @author Steve Ebersole
9+ */
10+ public class Sku {
11+ private String group ;
12+ private String department ;
13+ private String code ;
14+ }
Original file line number Diff line number Diff line change 1+
2+ <entity-mappings xmlns =" http://www.hibernate.org/xsd/orm/mapping"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ version =" 7.0" >
5+ <package >org.hibernate.orm.test.boot.models.xml.bad</package >
6+ <access >FIELD</access >
7+
8+ <entity class =" Product" metadata-complete =" true" >
9+ <attributes >
10+ <embedded-id name =" di" />
11+ <basic name =" name" />
12+ </attributes >
13+ </entity >
14+
15+ <embeddable class =" ProductKey" metadata-complete =" true" >
16+ <attributes >
17+ <basic name =" companyId" />
18+ <basic name =" sku" />
19+ </attributes >
20+ </embeddable >
21+ </entity-mappings >
Original file line number Diff line number Diff line change 1+
2+ <entity-mappings xmlns =" http://www.hibernate.org/xsd/orm/mapping"
3+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4+ version =" 7.0" >
5+ <package >org.hibernate.orm.test.boot.models.xml.bad</package >
6+ <access >FIELD</access >
7+
8+ <entity class =" Book" metadata-complete =" true" >
9+ <attributes >
10+ <id name =" id" />
11+ <basic name =" name" />
12+ <embedded name =" skew" />
13+ </attributes >
14+ </entity >
15+
16+ <embeddable class =" Sku" metadata-complete =" true" >
17+ <attributes >
18+ <basic name =" group" />
19+ <basic name =" department" />
20+ <basic name =" code" />
21+ </attributes >
22+ </embeddable >
23+ </entity-mappings >
You can’t perform that action at this time.
0 commit comments