[arquillian-issues] [JBoss JIRA] (ARQ-1942) Duplicate PK encountered when using a ApplyScriptBefore script

Dimitrios Kordas (JIRA) issues at jboss.org
Tue Apr 14 07:13:19 EDT 2015


    [ https://issues.jboss.org/browse/ARQ-1942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13058758#comment-13058758 ] 

Dimitrios Kordas commented on ARQ-1942:
---------------------------------------

After more testing i have determined the following:

Inside the dataset xml i am defining primary keys. These are inserted by persistence with no problem.
So if we were to use the above dataset, apps with the ids 2,3,4 would be inserted into the database.

Then, inside the test i am creating more apps using jpa/hibernate. If i create only one app, it will take the ID of 1 and no error will occur.
If i create more than one apps though, the 2nd will be assigned the ID 2 and it will raise a violation exception since the id2 already exists.

So i guess that the dataset script does not update the sequence table in PostgreSQL, and when hibernate starts it doesn't find any entries in the sequence and happilly and obliviously starts at ID 1 causing the problem.

Is this a misconfiguration on my part? Can this problem somehow be fixed using configuration for persistence?

Thanks for your time,
Dimitris

> Duplicate PK encountered when using a ApplyScriptBefore script
> --------------------------------------------------------------
>
>                 Key: ARQ-1942
>                 URL: https://issues.jboss.org/browse/ARQ-1942
>             Project: Arquillian
>          Issue Type: Bug
>          Components: Extension - Persistence
>    Affects Versions: persistence_1.0.0.Alpha6, persistence_1.0.0.Alpha7
>         Environment: Windows 8.1 Home, WildFly 8.2.0 Final, jdk1.8.0.40
>            Reporter: Dimitrios Kordas
>            Assignee: Bartosz Majsak
>
> I am trying to create tests for hibernate under WildFly 8.2.0.
> I can successfully create the war using Shrinkwrap, but when Arquillian tries to run the script i provided using the @ApplyScriptBefore annotation hibernate complains about duplicate primary keys even though all keys defined are sequential.
> I encounter this error for specific primary keys. For example 1.
> If i run the same script (only with an id of 2) multiple times it works.
> I have tested the same thing using yaml and json formats and it doesn't work either.
> INSERT INTO app_category(id, description, name) VALUES(1, 'entertainment apps', 'Entertainment');
> INSERT INTO app(id,active,fqn,name,app_category_id) VALUES(1,true,'com.facebook','Facebook',1);
> INSERT INTO app(id,active,fqn,name,app_category_id) VALUES(2,true,'com.twitter','Twitter',1);
> INSERT INTO app(id,active,fqn,name,app_category_id) VALUES(3,true,'com.instagram','Instagram',1);



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)


More information about the arquillian-issues mailing list