2014-09-16 4 views
0
Criteria cr=session.createCriteria(Student.class).add(Restrictions.between("strStudentMark1", "90", "100")); 

위의 코드 조각에서 나는 90과 100 사이의 점수를 부여했습니다. 학생 테이블에는 90과 100 사이의 표식이 있습니다. .최대 절전 모드 - 제한 사이()

무엇이 문제 일 수 있습니까? 내가 실수 한거야?

편집

내가 실행할 때 예 전체 목록을 얻고있다.

Criteria cr=session.createCriteria(Student.class); 

학생 엔티티는 생성 된 게터 및 설정자와 함께 아래에 있습니다.

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> 
+1

마크를 문자열로 저장하지 않았습니까? –

+0

빈에서 나는 'String'으로 표시를 선언하고 _Database_에서는 'Varchar2'로 표시를 저장했습니다 – Kaushi

+0

'strStudentMark1 Restrictions'을 추가하지 않으면 어떻게됩니까? 전체 목록을 얻고 있습니까? 그리고 학생 단체를 어떻게 정의 할 것이며, 최대 절전 모드 구성도 제공 할 수 있습니다. – dursun

답변

3

데이터베이스에 저장된 데이터가 INT인지 확인하십시오. 그 사이는 INT 데이터 유형에서만 작동합니다. 또한 코드에서 값을 int로 전달하십시오.

+0

예. DB의 데이터 타입이 NUMBER로 바뀌면 효과가있었습니다. 하지만 응용 프로그램에서 String을 전달해야합니다. 어쨌든 고마워 .... – Kaushi

관련 문제