신동훈 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63fc1ff... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZDAxMzM0ODlj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZDAxMz... ) HHH-16862 ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZDAxMz... ) Bad logs that occur when query collections when batchsize is applied ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiZDAxMz... )
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 setId(Long id) {
this.id = id;
}
public void setTeam(Team team) {
this.team = team;
}
public Long id() {
return id;
}
public Team team() {
return 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 void addMember(Member member) {
members.add(member);
}
public Long id() {
return id;
}
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:534ec1c )
신동훈 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63fc1ff... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNjUyZjE2MWVj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiNjUyZj... ) HHH-16862 ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiNjUyZj... ) Bad logs that occur when query collections when batchsize is applied ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiNjUyZj... )
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 setId(Long id) {
this.id = id;
}
public void setTeam(Team team) {
this.team = team;
}
public Long id() {
return id;
}
public Team team() {
return 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 void addMember(Member member) {
members.add(member);
}
public Long id() {
return id;
}
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:534ec1c )
신동훈 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63fc1ff... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmVhMzIxMGU2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiMmVhMz... ) HHH-16862 ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiMmVhMz... ) Bad logs that occur when query collections when batchsize is applied ( https://hibernate.atlassian.net/browse/HHH-16862?atlOrigin=eyJpIjoiMmVhMz... )
Issue Type: Bug Affects Versions: 6.2.2, 6.2.3, 6.2.4, 6.2.5 Assignee: Unassigned Attachments: 스크린샷 2023-06-28 오후 7.00.04.png Components: hibernate-core Created: 28/Jun/2023 03:01 AM Environment: any Labels: core Priority: Minor Reporter: 신동훈 ( 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
@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 setId( Long id) {
this.id = id;
}
public void setTeam(Team team) {
this.team = team;
}
public Long id() {
return id;
}
public Team team() {
return team;
}
}
@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 void addMember(Member member) {
members.add(member);
}
public Long id() {
return id;
}
public List<Member> members() {
return members;
}
}
@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());
}
}
application.yml
---------------
logging: level: root: info
org.hiberante. SQL: debug
org.hibernate.orm.jdbc. bind: trace
org.apache.coyote.http 11 : debug #Http ???? ?? ???
spring: datasource: driver-class- name: org.h 2.Driver
url: jdbc:h 2 :mem:testdb
username: sa
password:
h 2 :
console: enabled: true
path: /h 2 -console
jpa: show- sql: true
open-in- view: false
database- platform: org.hibernate.dialect.H 2 Dialect
properties: hibernate: format_ sql: true
use_sql_ comments: true
highlight_ sql: true
default_batch_fetch_ size: 100
hibernate: ddl- auto: create
and below is error log image.
( https://hibernate.atlassian.net/rest/api/3/attachment/content/50479 )
( 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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100227- sha1:534ec1c )