Skip to content

Commit 58e4c67

Browse files
EtienneMiretdreab8
authored andcommitted
HHH-9247 Add test for parsing named-attribute-nodes in orm.xml.
1 parent 9973e90 commit 58e4c67

File tree

5 files changed

+269
-0
lines changed

5 files changed

+269
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
25+
package org.hibernate.test.annotations.entityGraph;
26+
27+
import java.util.Date;
28+
import java.util.Set;
29+
30+
31+
/**
32+
* @author Etienne Miret
33+
*/
34+
public class Author {
35+
36+
private Long id;
37+
38+
private String name;
39+
40+
private Date birth;
41+
42+
private Set<Book> books;
43+
44+
public Author() {
45+
super();
46+
}
47+
48+
public Long getId() {
49+
return id;
50+
}
51+
52+
public String getName() {
53+
return name;
54+
}
55+
56+
public void setName(String name) {
57+
this.name = name;
58+
}
59+
60+
public Date getBirth() {
61+
return birth;
62+
}
63+
64+
public void setBirth(Date birth) {
65+
this.birth = birth;
66+
}
67+
68+
public Set<Book> getBooks() {
69+
return books;
70+
}
71+
72+
public void setBooks(Set<Book> books) {
73+
this.books = books;
74+
}
75+
76+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
25+
package org.hibernate.test.annotations.entityGraph;
26+
27+
import java.util.Set;
28+
29+
30+
/**
31+
* @author Etienne Miret
32+
*/
33+
public class Book {
34+
35+
private Long id;
36+
37+
private String isbn;
38+
39+
private String title;
40+
41+
private Set<Author> authors;
42+
43+
public Book() {
44+
super();
45+
}
46+
47+
public Long getId() {
48+
return id;
49+
}
50+
51+
public String getIsbn() {
52+
return isbn;
53+
}
54+
55+
public void setIsbn(String isbn) {
56+
this.isbn = isbn;
57+
}
58+
59+
public String getTitle() {
60+
return title;
61+
}
62+
63+
public void setTitle(String title) {
64+
this.title = title;
65+
}
66+
67+
public Set<Author> getAuthors() {
68+
return authors;
69+
}
70+
71+
public void setAuthors(Set<Author> authors) {
72+
this.authors = authors;
73+
}
74+
75+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
25+
package org.hibernate.test.annotations.entityGraph;
26+
27+
import org.hibernate.cfg.Configuration;
28+
import org.hibernate.internal.util.ConfigHelper;
29+
import org.hibernate.testing.TestForIssue;
30+
import org.junit.Test;
31+
32+
33+
/**
34+
* @author Etienne Miret
35+
*/
36+
public class OrmXmlParseTest {
37+
38+
@Test
39+
@TestForIssue( jiraKey = "HHH-9247" )
40+
public void parseNamedAttributeNode() {
41+
final Configuration cfg = new Configuration();
42+
cfg.addURL( ConfigHelper.findAsResource( "org/hibernate/test/annotations/entityGraph/orm.xml" ) );
43+
cfg.buildMappings();
44+
}
45+
46+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* Copyright (c) 2015, Red Hat Inc. or third-party contributors as
5+
* indicated by the @author tags or express copyright attribution
6+
* statements applied by the authors. All third-party contributions are
7+
* distributed under license by Red Hat Inc.
8+
*
9+
* This copyrighted material is made available to anyone wishing to use, modify,
10+
* copy, or redistribute it subject to the terms and conditions of the GNU
11+
* Lesser General Public License, as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16+
* for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with this distribution; if not, write to:
20+
* Free Software Foundation, Inc.
21+
* 51 Franklin Street, Fifth Floor
22+
* Boston, MA 02110-1301 USA
23+
*/
24+
25+
/**
26+
* This package groups tests about the JPA 2.1 Entity Graph feature.
27+
* See section 3.7 from the JPA 2.1 specification.
28+
*/
29+
package org.hibernate.test.annotations.entityGraph;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
3+
version="2.1">
4+
<package>org.hibernate.test.annotations.entityGraph</package>
5+
<access>FIELD</access>
6+
7+
<entity class="Book">
8+
<named-entity-graph name="basic">
9+
<named-attribute-node name="id"/>
10+
<named-attribute-node name="isbn"/>
11+
<named-attribute-node name="title"/>
12+
</named-entity-graph>
13+
<named-entity-graph name="full">
14+
<named-attribute-node name="id"/>
15+
<named-attribute-node name="isbn"/>
16+
<named-attribute-node name="title"/>
17+
<named-attribute-node name="authors" subgraph="authors"/>
18+
<subgraph name="authors" class="Author">
19+
<named-attribute-node name="id"/>
20+
<named-attribute-node name="name"/>
21+
<named-attribute-node name="birth"/>
22+
</subgraph>
23+
</named-entity-graph>
24+
<attributes>
25+
<id name="id"/>
26+
<basic name="isbn"/>
27+
<basic name="title"/>
28+
<many-to-many name="authors">
29+
<join-table name="book_author"/>
30+
</many-to-many>
31+
</attributes>
32+
</entity>
33+
34+
<entity class="Author">
35+
<attributes>
36+
<id name="id"/>
37+
<basic name="name"/>
38+
<basic name="birth"/>
39+
<many-to-many name="books" mapped-by="authors"/>
40+
</attributes>
41+
</entity>
42+
43+
</entity-mappings>

0 commit comments

Comments
 (0)