-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: No row with the given identifier exists (multithreading)
PostPosted: Fri Dec 01, 2017 12:24 pm 
Newbie

Joined: Fri May 26, 2017 10:59 am
Posts: 4
Hi all!

I have some issue when I perform http TestNG tests through multiple threads.

Code:
@Test
public void updateFrameWithData1() {
//create unique frame
// then update it
}

@Test
public void updateFrameWithData2() {
//create unique frame
// then update it
}

and so on.. multiple tests via for example 8 threads


If I run tests in one thread all is ok! But in the above case I got 500 error response - No row with the given identifier exists

And on the server I see such error:

Code:
javax.persistence.EntityNotFoundException: No row with the given identifier exists: [com.aginity.amp.catalogservice.domain.model.workspace.asset.frame.frame.FrameLogic#48951]
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:111)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
    at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1419)
    at


I have
Code:
hibernate.current_session_context_class: thread
for current session.
Hibernate version is 5.2.8

The structure of my classes:

Code:
public class Frame  {

@OneToOne(cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "frame_logic_key", referencedColumnName = "frame_logic_key")
private FrameLogic logic;

//other fields

}
@AttributeOverride(name = "id", column = @Column(name = "view_frame_logic_key"))
public class FrameLogic extends IdentifiedDomainObject {
// fields of class

}


So the relationship is unidirectional via "frame_logic_key" column in corresponding tables of Frame and FrameLogic.

The EntityNotFoundException causing code is in one of Repository method -

Code:
Collection<FrameReference> dependenciesOfFrame(AssetId frameId) {

       Query referencesQuery = this.getSession().createNativeQuery(
                "SELECT a.asset_id as frame_id,  fr.name .... WHERE a.asset_id=:frameId"
        );

        referencesQuery.setParameter("frameId", frameId.id());
        List<Object[]> frameIdsWithRefDetails = referencesQuery.list();

        Multimap<String, FrameReference> refDetailsByFrameId = convert(frameIdsWithRefDetails)
        Set<String> ids = refDetailsByFrameId.keySet();

        Query framesQuery = this.getSession().createQuery(
                    "from com.aginity.amp.catalogservice.domain.model.workspace.asset.frame.Frame as _obj_ "
                            + "where _obj_.assetId.id in (:ids)");

        framesQuery.setParameterList("ids", ids);
        Collection<Frame> frames = framesQuery.list(); // here is when exception occurs!

}


In either create or update frame flow it calls
Code:
dependenciesOfFrame()
to validate some business logic and after that it finally calls
Code:
this.getSession().saveOrUpdate(frame);


I am stuck where the problem can be.
Maybe https://stackoverflow.com/questions/5512138/calling-hibernate-query-list-method-generates-errors is somehow related to my problem but I am nor sure.

Any ideas why the issue may occur?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.