Criteria cr=session.createCriteria(Student.class).add(Restrictions.between("strStudentMark1", "90", "100"));
In the above code snippet, I have given the mark between 90 and 100. In the Student table, there are fields between marks 90 and 100. but am not getting those in the output.
What could be the problem? Am I making any mistake?
EDIT
Yes am getting the whole list when I run.
Criteria cr=session.createCriteria(Student.class);
Student entity is below with generated Getters and Setters.
import java.io.Serializable;
public class Student implements Serializable {
private String strStudentID;
private String strStudentRegNO;
private String strStudentName;
private String strStudentMark1;
private String strStudentMark2;
private String strStudentDegree;
private String strStudentMobileNO;
private String strStudentMailID;
private String strSalary;
public String getStrSalary() {
return strSalary;
}
public void setStrSalary(String strSalary) {
this.strSalary = strSalary;
}
public String getStrStudentID() {
return strStudentID;
}
public void setStrStudentID(String strStudentID) {
this.strStudentID = strStudentID;
}
public String getStrStudentRegNO() {
return strStudentRegNO;
}
public void setStrStudentRegNO(String strStudentRegNO) {
this.strStudentRegNO = strStudentRegNO;
}
public String getStrStudentName() {
return strStudentName;
}
public void setStrStudentName(String strStudentName) {
this.strStudentName = strStudentName;
}
public String getStrStudentMark1() {
return strStudentMark1;
}
public void setStrStudentMark1(String strStudentMark1) {
this.strStudentMark1 = strStudentMark1;
}
public String getStrStudentMark2() {
return strStudentMark2;
}
public void setStrStudentMark2(String strStudentMark2) {
this.strStudentMark2 = strStudentMark2;
}
public String getStrStudentDegree() {
return strStudentDegree;
}
public void setStrStudentDegree(String strStudentDegree) {
this.strStudentDegree = strStudentDegree;
}
public String getStrStudentMobileNO() {
return strStudentMobileNO;
}
public void setStrStudentMobileNO(String strStudentMobileNO) {
this.strStudentMobileNO = strStudentMobileNO;
}
public String getStrStudentMailID() {
return strStudentMailID;
}
public void setStrStudentMailID(String strStudentMailID) {
this.strStudentMailID = strStudentMailID;
}
}
hibernate.cfg.xml.
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@aaaa:bbbb</property>
<property name="connection.username">xxx</property>
<property name="connection.password">yyy</property>
<!-- <property name="connection.pool_size">5</property> -->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="current_session_context_class">thread</property>
<!-- <property name="hbm2ddl.auto">update</property> -->
<mapping resource="com/hibresources/Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Student.hbm.xml.
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 17 Dec, 2010 5:54:42 AM by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
<class name="com.bean.Student" table="STUDENT">
<meta attribute="class-description">
This class has details abt Students
</meta>
<id name="strStudentID" >
<column name="STUID" />
</id>
<property name="strStudentRegNO" >
<column name="STUREG_NO" />
</property>
<property name="strStudentName" >
<column name="STUNAME" />
</property>
<property name="strStudentMark1" >
<column name="STUMARK1" />
</property>
<property name="strStudentMark2" >
<column name="STUMARK2" />
</property>
<property name="strStudentDegree" >
<column name="DEGREE" />
</property>
<property name="strStudentMobileNO" >
<column name="MOBILENO" />
</property>
<property name="strStudentMailID" >
<column name="MAILID" />
</property>
<property name="strSalary" >
<column name="SALARY" />
</property>
</class>
</hibernate-mapping>