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:
//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;
//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:
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
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...
View Answers
April 5, 2011 at 6:35 PM
Have a look at the following link:
http://www.roseindia.net/hibernate/hibernate3quearyexample1.shtml
Related Tutorials/Questions & Answers:
Questions by Category
- Swing-AWT
- Date-Calendar
- JDBC
- Regex
- XML
- Security
- Java Server Faces
Questions
- JSP Servlet
- EJB
- JavaMail
- JMS
- Java3D
- Log4J
- Spring
- Hibernate
- Maven
- IDE Questions
- Mobile
Applications
- Ajax
- Framework
- Struts
- WebSevices
- Java Magazine
- JSP-Interview Questions
- Java
Interview Questions
- Servlet Interview Questions
-
Hibernate Interview Questions
- JUNIT
- Java Beginners
- Applet
- JNDI
- RMI
- LDAP
- RUP
- UML
- SQL
-
Design concepts & design patterns
- Ant
- CVS
- Subversion
- Development
process
- AOP
- IoC
- PHP