Skip to content

Commit

Permalink
HHH-13856 Fix Oracle failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Feb 10, 2020
1 parent 39091fc commit 5defe54
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
Expand Up @@ -22,13 +22,13 @@
name = "company.location",
fetchOverrides = {
@FetchProfile.FetchOverride(
entity = CompanyWithFetchProfile.class,
entity = CompanyFetchProfile.class,
association = "location",
mode = FetchMode.JOIN
)
}
)
public class CompanyWithFetchProfile {
public class CompanyFetchProfile {
@Id @GeneratedValue
public long id;

Expand All @@ -42,6 +42,7 @@ public class CompanyWithFetchProfile {
public Set<Market> markets = new HashSet<Market>();

@ElementCollection(fetch = FetchType.EAGER)
@JoinTable(name= "companyfp_phonenos")
public Set<String> phoneNumbers = new HashSet<String>();

public Location getLocation() {
Expand Down
@@ -1,4 +1,4 @@
package org.hibernate.jpa.test.graphs.mapped_by_id;
package org.hibernate.jpa.test.graphs.mappedbyid;

import org.hibernate.Hibernate;
import org.hibernate.Session;
Expand Down Expand Up @@ -99,12 +99,12 @@ public void testFetchGraphByFindTakingPrecedenceOverFetchProfile() {

entityManager.unwrap( Session.class ).enableFetchProfile("company.location");

EntityGraph<CompanyWithFetchProfile> entityGraph = entityManager.createEntityGraph( CompanyWithFetchProfile.class );
EntityGraph<CompanyFetchProfile> entityGraph = entityManager.createEntityGraph( CompanyFetchProfile.class );
entityGraph.addAttributeNodes( "markets" );

Map<String, Object> properties = Collections.singletonMap( "javax.persistence.fetchgraph", entityGraph );

CompanyWithFetchProfile company = entityManager.find( CompanyWithFetchProfile.class, companyWithFetchProfileId, properties );
CompanyFetchProfile company = entityManager.find( CompanyFetchProfile.class, companyWithFetchProfileId, properties );

entityManager.getTransaction().commit();
entityManager.close();
Expand All @@ -126,7 +126,7 @@ public void testFetchGraphByFindTakingPrecedenceOverFetchProfile() {
subSubgraph.addAttributeNodes( "managers" );
subSubgraph.addAttributeNodes( "friends" );

company = entityManager.find( CompanyWithFetchProfile.class, companyWithFetchProfileId, properties );
company = entityManager.find( CompanyFetchProfile.class, companyWithFetchProfileId, properties );

entityManager.getTransaction().commit();
entityManager.close();
Expand Down Expand Up @@ -189,25 +189,25 @@ public void createData() {
entityManager.persist( company );
companyId = company.id;

CompanyWithFetchProfile companyWithFetchProfile = new CompanyWithFetchProfile();
companyWithFetchProfile.employees.add( employee );
companyWithFetchProfile.employees.add( manager1 );
companyWithFetchProfile.employees.add( manager2 );
companyWithFetchProfile.location = location;
companyWithFetchProfile.markets.add( Market.SERVICES );
companyWithFetchProfile.markets.add( Market.TECHNOLOGY );
companyWithFetchProfile.phoneNumbers.add( "012-345-6789" );
companyWithFetchProfile.phoneNumbers.add( "987-654-3210" );
entityManager.persist( companyWithFetchProfile );
companyWithFetchProfileId = companyWithFetchProfile.id;
CompanyFetchProfile companyFetchProfile = new CompanyFetchProfile();
companyFetchProfile.employees.add( employee );
companyFetchProfile.employees.add( manager1 );
companyFetchProfile.employees.add( manager2 );
companyFetchProfile.location = location;
companyFetchProfile.markets.add( Market.SERVICES );
companyFetchProfile.markets.add( Market.TECHNOLOGY );
companyFetchProfile.phoneNumbers.add( "012-345-6789" );
companyFetchProfile.phoneNumbers.add( "987-654-3210" );
entityManager.persist( companyFetchProfile );
companyWithFetchProfileId = companyFetchProfile.id;

entityManager.getTransaction().commit();
entityManager.close();
}

@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { Company.class, CompanyWithFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
return new Class<?>[] { Company.class, CompanyFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
}

}
Expand Up @@ -4,7 +4,7 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.jpa.test.graphs.mapped_by_id;
package org.hibernate.jpa.test.graphs.mappedbyid;

import java.util.HashMap;
import java.util.Map;
Expand Down
Expand Up @@ -175,11 +175,11 @@ public void testFetchGraphTakingPrecedenceOverFetchProfile() {

entityManager.unwrap( Session.class ).enableFetchProfile( "company.location" );

EntityGraph<CompanyWithFetchProfile> entityGraph = entityManager.createEntityGraph( CompanyWithFetchProfile.class );
EntityGraph<CompanyFetchProfile> entityGraph = entityManager.createEntityGraph( CompanyFetchProfile.class );
entityGraph.addAttributeNodes( "markets" );
Query query = entityManager.createQuery( "from " + CompanyWithFetchProfile.class.getName() );
Query query = entityManager.createQuery( "from " + CompanyFetchProfile.class.getName() );
query.setHint( QueryHints.HINT_FETCHGRAPH, entityGraph );
CompanyWithFetchProfile company = (CompanyWithFetchProfile) query.getSingleResult();
CompanyFetchProfile company = (CompanyFetchProfile) query.getSingleResult();

entityManager.getTransaction().commit();
entityManager.close();
Expand All @@ -201,9 +201,9 @@ public void testFetchGraphTakingPrecedenceOverFetchProfile() {
subSubgraph.addAttributeNodes( "managers" );
subSubgraph.addAttributeNodes( "friends" );

query = entityManager.createQuery( "from " + CompanyWithFetchProfile.class.getName() );
query = entityManager.createQuery( "from " + CompanyFetchProfile.class.getName() );
query.setHint( QueryHints.HINT_FETCHGRAPH, entityGraph );
company = (CompanyWithFetchProfile) query.getSingleResult();
company = (CompanyFetchProfile) query.getSingleResult();

entityManager.getTransaction().commit();
entityManager.close();
Expand Down Expand Up @@ -508,23 +508,23 @@ public void createData() {
company.phoneNumbers.add( "987-654-3210" );
entityManager.persist( company );

CompanyWithFetchProfile companyWithFetchProfile = new CompanyWithFetchProfile();
companyWithFetchProfile.employees.add( employee );
companyWithFetchProfile.employees.add( manager1 );
companyWithFetchProfile.employees.add( manager2 );
companyWithFetchProfile.location = location;
companyWithFetchProfile.markets.add( Market.SERVICES );
companyWithFetchProfile.markets.add( Market.TECHNOLOGY );
companyWithFetchProfile.phoneNumbers.add( "012-345-6789" );
companyWithFetchProfile.phoneNumbers.add( "987-654-3210" );
entityManager.persist( companyWithFetchProfile );
CompanyFetchProfile companyFetchProfile = new CompanyFetchProfile();
companyFetchProfile.employees.add( employee );
companyFetchProfile.employees.add( manager1 );
companyFetchProfile.employees.add( manager2 );
companyFetchProfile.location = location;
companyFetchProfile.markets.add( Market.SERVICES );
companyFetchProfile.markets.add( Market.TECHNOLOGY );
companyFetchProfile.phoneNumbers.add( "012-345-6789" );
companyFetchProfile.phoneNumbers.add( "987-654-3210" );
entityManager.persist( companyFetchProfile );

entityManager.getTransaction().commit();
entityManager.close();
}

@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] { Company.class, CompanyWithFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
return new Class<?>[] { Company.class, CompanyFetchProfile.class, Employee.class, Manager.class, Location.class, Course.class, Student.class };
}
}

0 comments on commit 5defe54

Please sign in to comment.