신동훈 (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63fc1ff...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTkzNzI3OTBm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZTkzNz...
) HHH-16862 (
https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZTkzNz...
) Bad logs that occur when query collections when batchsize is applied (
https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZTkzNz...
)
Change By: 신동훈 (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63fc1ff...
)
The remaining elements of the array are returned as null when querying the collection
after applying the batch size.
For example, if the batch size is 100 and only 1 id is entered, 99 nulls are bound.Below
is the example code
{code:java}@Entity
public class Member {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@ManyToOne
@JoinColumn(name = "team_id")
private Team team;
protected Member() {
}
public void setTeam(Team team) {
this.team = team;
}
}
{code}
{code:java}@Entity
public class Team {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@OneToMany(mappedBy = "team")
private List<Member> members = new ArrayList<>();
public List<Member> members() {
return members;
}
}
{code}
{code:java}@Transactional
@SpringBootTest
class MemberTest {
@Autowired
private EntityManager em;
@Test
void error() {
Team team = new Team();
em.persist(team);
em.flush();
Member member = new Member();
member.setTeam(team);
em.persist(member);
em.flush();
em.clear();
Team team1 = em.find(Team.class, 1L);
System.out.println(team1.members().size());
}
}
{code}
h3. application.yml
{code:yaml}
logging:
level:
root: info
org.hiberante.SQL: debug
org.hibernate.orm.jdbc.bind: trace
org.apache.coyote.http11: debug #Http ???? ?? ???
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb
username: sa
password:
h2:
console:
enabled: true
path: /h2-console
jpa:
show-sql: true
open-in-view: false
database-platform: org.hibernate.dialect.H2Dialect
properties:
hibernate:
format_sql: true
use_sql_comments: true
highlight_sql: true
default_batch_fetch_size: 100
hibernate:
ddl-auto: create
{code}
and below is error log image.
!스크린샷 2023-06-28 오후 7.00.04.png|width=1388,height=979!
This is likely because the CollectionBatchLoaderArrayParam class, the return value of the
StandardBatchLoaderFactory.createCollectionBatchLoader() method, is assigned to a
reusablecollectionLoader inside the AbstractCollectionPersister.createCollectionLoader()
method and then reused.
In order to use the CollectionBatchLoaderArrayParam in any case inside
StandardBatchLoaderFactory.createCollectionBatchLoader(), it seems that we need to do
something about the logs.
(
https://hibernate.atlassian.net/browse/HHH-16862#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16862#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:534ec1c )