Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnidirectionalOrderedOneToManyTest failed delete only 1st entry #22

Closed
wants to merge 1 commit into from
Closed

UnidirectionalOrderedOneToManyTest failed delete only 1st entry #22

wants to merge 1 commit into from

Conversation

senleft
Copy link

@senleft senleft commented May 5, 2018

Hello,

The UnidirectionalOrderedOneToManyTest failed for "delete only 1st entry" case
The reason is Hibernate generated SQL and as result the integrity constraint violation between //2 and //3 table rows
See details in below log.
Is it expected?
Regards, Alex

drop table post if exists|
drop table post_comment if exists|
drop table post_post_comment if exists|
drop sequence hibernate_sequence if exists|
create sequence hibernate_sequence start with 1 increment by 1|
create table post (id bigint not null, title varchar(255), primary key (id))|
create table post_comment (id bigint not null, review varchar(255), primary key (id))
create table post_post_comment (Post_id bigint not null, comments_id bigint not null, entry integer not null, primary key (Post_id, entry))
alter table post_post_comment add constraint UK_gb03lqukc5jc1u847l17m311q unique (comments_id)
alter table post_post_comment add constraint FKp3qg7d2x7uh1eiulxe65rhwl2 foreign key (comments_id) references post_comment
alter table post_post_comment add constraint FKdylii52824tsuhxvxsnancr51 foreign key (Post_id) references post
insert into post_comment (review, id) values ('My first review', 2)
insert into post_comment (review, id) values ('My second review', 3)
insert into post_comment (review, id) values ('My third review', 4)
insert into post_post_comment (Post_id, entry, comments_id) values (1, 0, 2)//2 - row updated and integrity constraint violation with row 3
insert into post_post_comment (Post_id, entry, comments_id) values (1, 1, 3)//3
**insert into post_post_comment (Post_id, entry, comments_id) values (1, 2, 4)//1 - row deleted
- Remove head
- Deleted PostComment{id=2, review='My first review'}
delete from post_post_comment where Post_id=1 and entry=2 //1
update post_post_comment set comments_id=3 where Post_id=1 and entry=0//2
SQL Error: -104, SQLState: 23505
integrity constraint violation: unique constraint or index violation; UK_GB03LQUKC5JC1U847L17M311Q table: POST_POST_COMMENT

@vladmihalcea
Copy link
Owner

It works just fine for me. Just take a look on the log:

DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:49, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["drop table if exists hibernate_sequence"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:3, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["drop table if exists post"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["drop table if exists post_comment"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["drop table if exists post_post_comment"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:38, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["create table hibernate_sequence (next_val bigint) engine=InnoDB"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:9, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into hibernate_sequence values ( 1 )"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:4, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into hibernate_sequence values ( 1 )"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:41, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["create table post (id bigint not null, title varchar(255), primary key (id)) engine=InnoDB"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:37, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["create table post_comment (id bigint not null, review varchar(255), primary key (id)) engine=InnoDB"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:44, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["create table post_post_comment (Post_id bigint not null, comments_id bigint not null, entry integer not null, primary key (Post_id, entry)) engine=InnoDB"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:56, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["alter table post_post_comment add constraint UK_gb03lqukc5jc1u847l17m311q unique (comments_id)"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:115, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["alter table post_post_comment add constraint FKp3qg7d2x7uh1eiulxe65rhwl2 foreign key (comments_id) references post_comment (id)"], Params:[]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:95, Success:True, Type:Statement, Batch:False, QuerySize:1, BatchSize:0, Query:["alter table post_post_comment add constraint FKdylii52824tsuhxvxsnancr51 foreign key (Post_id) references post (id)"], Params:[]
INFO  [Alice]: o.h.t.s.i.SchemaCreatorImpl - HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@6d4a65c6'
WARN  [Alice]: b.t.Configuration - cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!).
WARN  [Alice]: b.t.j.DiskJournal - active log file is unclean, did you call BitronixTransactionManager.shutdown() at the end of the last run?
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:13, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(2, 1)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(3, 2)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(4, 3)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["select next_val as id_val from hibernate_sequence for update"], Params:[()]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update hibernate_sequence set next_val= ? where next_val=?"], Params:[(5, 4)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:4, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post (title, id) values (?, ?)"], Params:[(First post, 1)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:3, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_comment (review, id) values (?, ?)"], Params:[(My first review, 2)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_comment (review, id) values (?, ?)"], Params:[(My second review, 3)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_comment (review, id) values (?, ?)"], Params:[(My third review, 4)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:3, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_post_comment (Post_id, entry, comments_id) values (?, ?, ?)"], Params:[(1, 0, 2)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_post_comment (Post_id, entry, comments_id) values (?, ?, ?)"], Params:[(1, 1, 3)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:6, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into post_post_comment (Post_id, entry, comments_id) values (?, ?, ?)"], Params:[(1, 2, 4)]
INFO  [Alice]: c.v.b.h.h.a.UnidirectionalOrderedOneToManyTest - Remove tail
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:2, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["delete from post_post_comment where Post_id=? and entry=?"], Params:[(1, 2)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["delete from post_comment where id=?"], Params:[(4)]
INFO  [Alice]: c.v.b.h.h.a.UnidirectionalOrderedOneToManyTest - Remove head
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["delete from post_post_comment where Post_id=? and entry=?"], Params:[(1, 1)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["update post_post_comment set comments_id=? where Post_id=? and entry=?"], Params:[(3, 1, 0)]
DEBUG [Alice]: n.t.d.l.SLF4JQueryLoggingListener - Name:DATA_SOURCE_PROXY, Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["delete from post_comment where id=?"], Params:[(2)]

@senleft
Copy link
Author

senleft commented May 6, 2018 via email

@vladmihalcea
Copy link
Owner

Most likely, you bumped into some Hibernate bug. I remember seeing something similar on Jira lately.

@senleft
Copy link
Author

senleft commented May 6, 2018

Hello,

Should I report the bug or it already reported?
I checked the mentioned case with Derby, DB2, H2 and with Hibernate and EclipseLink and it reproduced for all combinations.

Regards, Aleksandr

@vladmihalcea
Copy link
Owner

vladmihalcea commented May 6, 2018 via email

@senleft senleft changed the title UnidirectionalOrderedOneToManyTest failed delete 1st entry UnidirectionalOrderedOneToManyTest failed delete only 1st entry May 6, 2018
@senleft
Copy link
Author

senleft commented May 6, 2018

Done, HHH-12548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants