We're updating the issue view to help you get more done. 

Use of @NotFound(IGNORE) and @BatchSize when there are unresolved foreign key values results in extra queries

Description

When accessing a unidirectional OneToOne association where there are unresolvable foreign key references when batching is enabled with @NotFound(IGNORE), each association access in a loop re-queries for all the unresolved foreign keys:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 [2017-09-06 13:36:52] DEBUG [org.hibernate.engine.jdbc.spi.SqlStatementLogger] select employee0_.name as name1_0_, employee0_.task_id as task_id2_0_ from Employee employee0_ [2017-09-06 13:36:52] DEBUG [org.hibernate.engine.jdbc.spi.SqlStatementLogger] select task0_.id as id1_1_0_, task0_.name as name2_1_0_ from Task task0_ where task0_.id in ( ?, ? ) [2017-09-06 13:36:52] TRACE [org.hibernate.type.descriptor.sql.BasicBinder] binding parameter [1] as [BIGINT] - [1] [2017-09-06 13:36:52] TRACE [org.hibernate.type.descriptor.sql.BasicBinder] binding parameter [2] as [BIGINT] - [2] [2017-09-06 13:36:52] DEBUG [org.hibernate.engine.jdbc.spi.SqlStatementLogger] select task0_.id as id1_1_0_, task0_.name as name2_1_0_ from Task task0_ where task0_.id in ( ?, ? ) [2017-09-06 13:36:52] TRACE [org.hibernate.type.descriptor.sql.BasicBinder] binding parameter [1] as [BIGINT] - [2] [2017-09-06 13:36:52] TRACE [org.hibernate.type.descriptor.sql.BasicBinder] binding parameter [2] as [BIGINT] - [1]

In the log capture above, the second query is redundant and unexpected.

Environment

None

Status

Assignee

Gail Badner

Reporter

Stephen Fikes

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.14
5.2.10

Priority

Major