[JIRA] (HHH-16367) H6: Problem with flush and batch is ON
by Danilov Roman (JIRA)
Danilov Roman ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNWQ5NTQ4YjUz... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16367?atlOrigin=eyJpIjoiNWQ5NT... ) HHH-16367 ( https://hibernate.atlassian.net/browse/HHH-16367?atlOrigin=eyJpIjoiNWQ5NT... ) H6: Problem with flush and batch is ON ( https://hibernate.atlassian.net/browse/HHH-16367?atlOrigin=eyJpIjoiNWQ5NT... )
Issue Type: Bug Affects Versions: 6.2.0.CR4 Assignee: Unassigned Attachments: hibernate-orm-6.zip Components: hibernate-core Created: 24/Mar/2023 07:32 AM Priority: Major Reporter: Danilov Roman ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... )
Hello.
I have two entites:
@Entity
@DynamicUpdate
@Table(name = "laterals")
public class Lateral extends Well implements Serializable {
@Column(name = "id", insertable = false, updatable = false, nullable = false, columnDefinition = "serial")
@Generated(GenerationTime.INSERT)
public Long id;
public Long diameter;
public Long diameter1;
public String paka1;
public String paka2;
}
and
@Entity
@DynamicUpdate
@Table(name = "wells")
@Inheritance(strategy = InheritanceType.JOINED)
public class Well {
@Id
public UUID uuid;
public String name;
public String name1;
public String name2;
public long gui1;
public long gui2;
}
And when first we select one Lateral ,
String hql = "from `Lateral` where uuid = ?1";
Query query = entityManager.createQuery(hql);
query.setParameter(1, uuid);
Lateral lateral = (Lateral) query.getSingleResult();
In the console showed select request.
select * from laterals ...
Then we are begining to change element’s params:
lateral.setName("TEST2");
lateral.setName1("TEST12");
Then we make another any select request:
String hql2 = "from Well where uuid = ?1";
Query query2 = entityManager.createQuery(hql2);
query2.setParameter(1, uuid);
Object object = query2.getSingleResult();
In the console we see update query (with two changed params) and second select query:
update wells set name=?, name1=? where uuid=?
select * from wells ...
Then we are changing more parameters and do persist and flush:
lateral.setDiameter(55L);
lateral.setDiameter1(55L);
lateral.setPaka1("PAKA1");
lateral.setPaka1("PAKA2");
lateral.setName("TEST3");
lateral.setName1("TEST13");
lateral.setName2("TEST23");
lateral.setGui1(111L);
lateral.setGui2(222L);
entityManager.persist(lateral);
entityManager.flush();
And In the console we see update query (with *two* *old params* ) and error:
update wells set name=?, name1=? where uuid=?
2023-03-24 18:21:13 TRACE bind:28 - binding parameter [1] as [BIGINT] - [111]
2023-03-24 18:21:13 TRACE bind:28 - binding parameter [2] as [BIGINT] - [222]
2023-03-24 18:21:13 TRACE bind:28 - binding parameter [3] as [VARCHAR] - [TEST3]
2023-03-24 18:21:13 TRACE bind:28 - binding parameter [4] as [VARCHAR] - [TEST13]
2023-03-24 18:21:13 WARN SqlExceptionHelper:145 - SQL Error: 90008, SQLState: 90008
2023-03-24 18:21:13 ERROR SqlExceptionHelper:150 - Invalid value "4" for parameter "parameterIndex" [90008-214]
1) It turns out that before the second select request the makes a flush although I didn't call him?
2) and after my flush it makes the old update request but with new list of parameters.
Without “batch” everything works without errors (and on hibernate 5 too).
Test cases attached.
( https://hibernate.atlassian.net/browse/HHH-16367#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16367#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#100219- sha1:ac3e918 )
3 years