Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-9965 : Pagination ignored on collection fetch join: Add the abili…
…ty to throw an exception instead of logging a warn (cherry picked from commit b711e14)
- Loading branch information
1 parent
d34f026
commit dbd7135
Showing
10 changed files
with
193 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
hibernate-core/src/test/java/org/hibernate/test/pagination/hhh9965/HHH9965Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* 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.test.pagination.hhh9965; | ||
|
||
import org.hibernate.Session; | ||
import org.hibernate.cfg.Configuration; | ||
import org.hibernate.cfg.Environment; | ||
import org.hibernate.testing.TestForIssue; | ||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* Created on 17/12/17. | ||
* | ||
* @author Reda.Housni-Alaoui | ||
*/ | ||
@TestForIssue(jiraKey = "HHH-9965") | ||
public class HHH9965Test extends BaseCoreFunctionalTestCase { | ||
|
||
@Test | ||
public void testHHH9965() { | ||
Session session = openSession(); | ||
session.beginTransaction(); | ||
|
||
String hql = "SELECT s FROM Shop s join fetch s.products"; | ||
|
||
try{ | ||
session.createQuery(hql) | ||
.setMaxResults(3) | ||
.list(); | ||
fail("Pagination over collection fetch failure was expected"); | ||
} catch (Exception e){ | ||
log.info(e.getMessage()); | ||
} | ||
finally { | ||
session.getTransaction().rollback(); | ||
session.close(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void configure(Configuration cfg) { | ||
super.configure(cfg); | ||
cfg.setProperty( Environment.FAIL_ON_PAGINATION_OVER_COLLECTION_FETCH, "true"); | ||
} | ||
|
||
@Override | ||
protected Class<?>[] getAnnotatedClasses() { | ||
return new Class<?>[]{ | ||
Shop.class, | ||
Product.class | ||
}; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
hibernate-core/src/test/java/org/hibernate/test/pagination/hhh9965/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* 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.test.pagination.hhh9965; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.Id; | ||
|
||
/** | ||
* Created on 17/12/17. | ||
* | ||
* @author Reda.Housni-Alaoui | ||
*/ | ||
@Entity | ||
public class Product { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
hibernate-core/src/test/java/org/hibernate/test/pagination/hhh9965/Shop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Hibernate, Relational Persistence for Idiomatic Java | ||
* | ||
* 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.test.pagination.hhh9965; | ||
|
||
import javax.persistence.*; | ||
import java.util.List; | ||
|
||
/** | ||
* Created on 17/12/17. | ||
* | ||
* @author Reda.Housni-Alaoui | ||
*/ | ||
@Entity | ||
public class Shop { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@OneToMany(fetch = FetchType.LAZY) | ||
private List<Product> products; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public List<Product> getProducts() { | ||
return products; | ||
} | ||
|
||
public void setProducts(List<Product> products) { | ||
this.products = products; | ||
} | ||
|
||
} |