Skip to content

Commit b3ef2de

Browse files
koentsjesebersole
authored andcommitted
HHH-13233: Remove commit d8faee0 by David Steinkopff <david.steinkopff@x-root.de>
1 parent c64e3b9 commit b3ef2de

File tree

1 file changed

+1
-99
lines changed

1 file changed

+1
-99
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/EntityGraphUsingFetchGraphTest.java

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
*/
55
package org.hibernate.orm.test.entitygraph;
66

7-
import java.util.Collection;
87
import java.util.Date;
98
import java.util.List;
10-
import jakarta.persistence.AttributeNode;
9+
1110
import jakarta.persistence.Entity;
1211
import jakarta.persistence.EntityGraph;
1312
import jakarta.persistence.EntityManager;
@@ -21,8 +20,6 @@
2120
import jakarta.persistence.Temporal;
2221
import jakarta.persistence.TemporalType;
2322
import jakarta.persistence.TypedQuery;
24-
import jakarta.persistence.metamodel.Attribute;
25-
import jakarta.persistence.metamodel.EntityType;
2623

2724
import org.hibernate.graph.GraphSemantic;
2825

@@ -32,9 +29,7 @@
3229
import org.hibernate.testing.orm.junit.SessionFactoryScope;
3330
import org.junit.jupiter.api.Test;
3431

35-
import static org.hamcrest.CoreMatchers.is;
3632
import static org.hamcrest.MatcherAssert.assertThat;
37-
import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize;
3833
import static org.hibernate.testing.hamcrest.InitializationCheckMatcher.isInitialized;
3934

4035
/**
@@ -143,68 +138,6 @@ void fetchAttributeNodeByStringFromSubgraph(SessionFactoryScope scope) {
143138
query.setHint( GraphSemantic.LOAD.getJpaHintName(), entityGraph );
144139
final List<CustomerOrder> results = query.getResultList();
145140

146-
assertEntityGraph( entityGraph );
147-
assertThat( results, isInitialized() );
148-
}
149-
);
150-
}
151-
152-
@Test
153-
@JiraKey( value = "HHH-13233")
154-
@SuppressWarnings({ "unchecked", "rawtypes" })
155-
void fetchAttributeNodeByAttributeFromSubgraph(SessionFactoryScope scope) {
156-
scope.inTransaction(
157-
session -> {
158-
Address address = new Address();
159-
address.city = "TestCity";
160-
161-
CustomerOrder customerOrder = new CustomerOrder();
162-
customerOrder.shippingAddress = address;
163-
164-
Product product = new Product();
165-
166-
OrderPosition orderPosition = new OrderPosition();
167-
orderPosition.product = product;
168-
169-
customerOrder.orderPosition = orderPosition;
170-
session.persist( address );
171-
session.persist( orderPosition );
172-
session.persist( product );
173-
session.persist( customerOrder );
174-
}
175-
);
176-
177-
scope.inTransaction(
178-
session -> {
179-
final EntityManager em = session.unwrap( EntityManager.class );
180-
final EntityGraph<CustomerOrder> entityGraph = em.createEntityGraph( CustomerOrder.class );
181-
EntityType<CustomerOrder> customerOrderEntityType =
182-
scope.getSessionFactory().getMetamodel().entity( CustomerOrder.class );
183-
entityGraph.addAttributeNodes(
184-
customerOrderEntityType.getAttribute( "shippingAddress" ),
185-
customerOrderEntityType.getAttribute( "orderDate" )
186-
);
187-
entityGraph.addAttributeNodes( customerOrderEntityType.getAttribute( "shippingAddress" ) );
188-
189-
final Subgraph<OrderPosition> orderProductsSubgraph =
190-
entityGraph.addSubgraph( (Attribute) customerOrderEntityType.getAttribute( "orderPosition" ) );
191-
EntityType<OrderPosition> positionEntityType =
192-
scope.getSessionFactory().getMetamodel().entity( OrderPosition.class );
193-
orderProductsSubgraph.addAttributeNodes( positionEntityType.getAttribute( "amount" ) );
194-
orderProductsSubgraph.addAttributeNodes( positionEntityType.getAttribute( "product" ) );
195-
196-
final Subgraph<Product> productSubgraph =
197-
orderProductsSubgraph.addSubgraph( (Attribute) positionEntityType.getAttribute( "product" ) );
198-
EntityType<Product> productEntityType = scope.getSessionFactory().getMetamodel().entity( Product.class );
199-
productSubgraph.addAttributeNodes( productEntityType.getAttribute( "productName" ) );
200-
201-
TypedQuery<CustomerOrder> query = em.createQuery(
202-
"SELECT o FROM CustomerOrder o", CustomerOrder.class
203-
);
204-
query.setHint( GraphSemantic.LOAD.getJpaHintName(), entityGraph );
205-
final List<CustomerOrder> results = query.getResultList();
206-
207-
assertEntityGraph( entityGraph );
208141
assertThat( results, isInitialized() );
209142
}
210143
);
@@ -250,37 +183,6 @@ void fetchUsingHql(SessionFactoryScope scope) {
250183
);
251184
}
252185

253-
/**
254-
* Verify that entityGraph has expected state
255-
*
256-
* customerOrder - shippingAddress
257-
* - orderDate
258-
* - orderPosition - amount
259-
* - product - productName
260-
*
261-
* @param entityGraph entityGraph
262-
*/
263-
private void assertEntityGraph(EntityGraph<CustomerOrder> entityGraph) {
264-
assertThat(entityGraph.getAttributeNodes(), hasSize( 3 ) );
265-
for ( AttributeNode<?> entityGraphAttributeNode : entityGraph.getAttributeNodes() ) {
266-
if ( "orderPosition".equals( entityGraphAttributeNode.getAttributeName() ) ) {
267-
Collection<Subgraph> orderPositionGraph = entityGraphAttributeNode.getSubgraphs().values();
268-
assertThat( orderPositionGraph, hasSize( 1 ) );
269-
List<AttributeNode<?>> orderPositionAttributes = orderPositionGraph.iterator().next().getAttributeNodes();
270-
assertThat( orderPositionAttributes, hasSize( 2 ) );
271-
for ( AttributeNode<?> orderPositionAttributeNode : orderPositionAttributes ) {
272-
if ( "product".equals( orderPositionAttributeNode.getAttributeName() ) ) {
273-
assertThat( orderPositionAttributeNode.getSubgraphs().entrySet(), hasSize( 1 ) );
274-
} else {
275-
assertThat( orderPositionAttributeNode.getSubgraphs().isEmpty(), is( true ) );
276-
}
277-
}
278-
} else {
279-
assertThat( entityGraphAttributeNode.getSubgraphs().isEmpty(), is( true ) );
280-
}
281-
}
282-
}
283-
284186
@Entity(name = "CustomerOrder")
285187
@Table(name = "customerOrder")
286188
public static class CustomerOrder {

0 commit comments

Comments
 (0)