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.  [ 5 posts ] 
Author Message
 Post subject: Calling hibernate query list() method generates errors
PostPosted: Sun Apr 03, 2011 11:02 pm 
Newbie

Joined: Sun Apr 03, 2011 10:52 pm
Posts: 3
Hello,

I'm trying to debug someone's codes. But I am not an expert of hibernate so I'm asking your help about this.

I am trying to retrieve a list of jobs from the database, but there seems to be a problem.

In the entity class:

Code:
//JobEntity

    @ManyToOne(cascade={CascadeType.MERGE, CascadeType.REFRESH}, fetch=FetchType.EAGER)
    @JoinColumn(name="job_id", nullable=false)
    private Job jobId;

    @Column(name="grp_id")
    private String grpId;

    @Id
    @Column(name="id", nullable=false)
    @GenericValue(strategy=GenerationType.SEQUENCE,generator="JOB_ENTITY_SEQUENCE")
    private Integer id;

----
Code:
//DaoImpl

    public Collection<JobEntity> getJobsByGrpId(String grpId){
        Query q = getCurrentSession().createQuery("from JobEntity je where je.grpId= :grpId order by je.id");

        q.setString("grpId", grpId);

        return q.list();
    }


And the error I get is something like this:

Code:
No row with the given identifier exists: [Job#:jb4567]...


But in the db, the table has data.

I'm not sure what's reason for this.

I tried putting a
Code:
getCurrentSession.flush()
statement before creating the query, and I also tried changing the cascade type of the job id from REFRESH to PERSIST, but still the same errors occur.

Does cache have anything to do with this? Or, what seems to be the problem here? I'm clueless already.

Thanks in advance for the answers...


Top
 Profile  
 
 Post subject: Re: Calling hibernate query list() method generates errors
PostPosted: Mon Apr 04, 2011 12:55 am 
Regular
Regular

Joined: Wed Apr 25, 2007 11:44 pm
Posts: 59
set the hibernate property hibernate.show.sql to true and observe the output in the console

does that produces the same query that you were expecting


Top
 Profile  
 
 Post subject: Re: Calling hibernate query list() method generates errors
PostPosted: Mon Apr 04, 2011 1:37 am 
Newbie

Joined: Sun Apr 03, 2011 10:52 pm
Posts: 3
msj4u wrote:
set the hibernate property hibernate.show.sql to true and observe the output in the console

does that produces the same query that you were expecting



Thanks for the advice.. I'll try looking at the log file for this..
though, I already tried logging (log4j) , and the query produced was the same as what the code above specified..

I really wonder what the cause of this is..


Top
 Profile  
 
 Post subject: Re: Calling hibernate query list() method generates errors
PostPosted: Mon Apr 04, 2011 2:51 am 
Newbie

Joined: Sun Apr 03, 2011 10:52 pm
Posts: 3
the sql logs are fine.. :(
what are the other possible causes here?


Top
 Profile  
 
 Post subject: Re: Calling hibernate query list() method generates errors
PostPosted: Thu Apr 07, 2011 1:16 am 
Regular
Regular

Joined: Wed Apr 25, 2007 11:44 pm
Posts: 59
hmm

that doesn't look good

are you using the database other than hibernate as well; it could be possible that the row with JOB#jb4567 is deleted by the other app or in the database manually


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

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.