Incomplete collections using join fetch queries
JPA-70
Simple Query with guarded Null Value fails with Apache Derby
JPA-28
Exception in AbstractEntityManagerImpl not logged to the user
JPA-20
Incorrect Generics signature for javax.persistence.criteria.CriteriaBuilder.SimpleCase<C, R>
JPA-9
JPA Support of Enum as Primary Key
JPA-7
Add Attribute#getJavaType(Class)
JPA-82
JPA AssociationOverrideS @ForeignKey not applied
JPA-78
[Смотреть онлайн] Реал Мадрид – Манчестер Сити 4 май 2016
JPA-77
ERROR: HHH000099: an assertion failure occured
JPA-74
AttributeConverter's convertToDatabaseColumn is called on save, but convertToEntityAttribute is not called when returning the saved entity.
JPA-72
2 persistent units with parameter generatedll=true --> All entities are generated in the 2 databases
JPA-68
Misleading Javadoc in javax.persistence.ForeignKey
JPA-64
Inheritance mapping with sqlresultsetmapping gives an undefined column name was detected
JPA-50
Parameter value List<Integer> was not matching type Integer
JPA-49
@Lob on String does not produce expected results for PostgreSQL
JPA-48
Table column doesnt get dropped when getter method name is changed
JPA-47
Issue with Inheritance mapping and one to many relationship for child
JPA-46
org.hibernate.HibernateException: Wrong column type in for column. Found: smallint, expected: integer
JPA-37
SingularAttributeImpl.isAssociation() always returns false
JPA-36
Date query not working
JPA-35
JDBC begin failed
JPA-33
Hibernate EntityManager does not allow changing database connection information after EntityManagerFactory creation
JPA-25
Isolation concurrency between persistence context
JPA-23
EntityManager.contains unsupport Entity enhanced by CGLIB
JPA-22
Many-to-Many: Unnecessary Table Join in generated SQL
JPA-19
indexed column treated like a PK
JPA-18
OPTIMISTIC_FORCE_INCREMENT is not incrementing version field of non-dirty entities
JPA-14
JPA Query Language
JPA-13
Cannot use { in string literal of native SQL query
JPA-12
@Lob annotation applies to both key and value of Map
JPA-11
JPA Criteria API Typesafety on equal
JPA-10
@ManyToOne target using Single Table inheritance type
JPA-6
PersistenceUtil.isLoaded() fails with a ClassCastException in Websphere 7
JPA-4
Add suport for right join to criteria API
JPA-2
many-to-one id="true" is not picked up by hibernate in orm.xml
JPA-1
NullPointerException in StatefulPersistenceContext.clear
JPA-76
Consistently use one indentation style
JPA-60
Generate 'on delete cascade' and 'on update cascade' with hbm2ddl tool for @ElementCollection generated foreign key
JPA-58
high-performance reading using non-jta datasource
JPA-26
duplicated id column when abstract id methods are defined in a @MappedSuperclass
JPA-16
Using JPA, order of database columns are reverse of how they appear in XML metadata!
JPA-5
maven : add IssueManagement declaration
JPA-59
issue 1 of 42

Incomplete collections using join fetch queries

Description

This is similar to but with some modifications to what is expected:

Supose we have those entities:

Detail (with an ID and a description)
Master (with an ID, a description and a collection of Details)

If we write this JPQL: "SELECT master FROM Master master JOIN master.details details WHERE details.description=:description" and pass a value to ":description", we have as a result some instances of Master that, will have all details that belong to master. This is correct and expected!

If we now write this JPQL in another session: "SELECT master FROM Master master JOIN FETCH master.details details WHERE details.description=:description" and pass a value to ":description", we have as a result some instances of Master that, despite having multiple details into the database, will have only the details that matches the WHERE clause. This is not correct since the condition should only filter the masters returned but not the details!

Now, if we write a different JPQL: "SELECT master FROM Master master JOIN FETCH master.details WHERE master.id=:id" and use as ":id" the primary key of the master we got from the previous query, the instance of Master returned by Hibernate will have only the details it had in the first query, despite the fact that the second query doesn't filter details at all.

For this bug to happen we must use the same entity manager for both queries. If we create another entity manager the bug doesn't happen and also if we call "EntityManager.clear()" before the second query all details are returned, meaning probably the bug is in how Hibernate stores entities in the first level cache.

TEST-CASE

https://github.com/Dancovich/hibernate-fetch-test/tree/master/hibernate-fetch-test

This is a simple Maven project stored at github with a JUnit test that shows the issue. It is a simple project with only hibernate-entitymanager, hsqldb and junit as dependencies. The test class is "MasterDAOTest".

Environment

None

Status

Assignee

Unassigned

Reporter

Detlef Höffner

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Affects versions

2.1.1

Priority

Blocker