yadan
2003-09-02 08:36
试试这样:

Query q = session.createQuery("from resumeDTO resume where resume.userID = :userID");

q.setString("userID", userId);

q.list();

...................

另外,你的resumeDTO 类是在mapping文件中和resume表映射的类吗?看起来怎么像一个VO类啊。

chenkl
2003-09-02 10:10
hibernate中查询的实质是一样的(在源码中可以看出来)。用query也没有成功,不知道是什么原因,请大虾指教

yehs220
2003-09-02 10:13
Query q = session.createQuery("from resumeDTO resume where resume.userID = :userID");

q.setString("userID", userId);

List l=q.list();

应该没错

>用query也没有成功<

你总得给出错误信息吧。

要不就是你的mapping有错。

chenkl
2003-09-02 10:28
我想应该不是我的hbm的问题,因为我保存是可以成功的。

这是我的hbm:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping

PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"

"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.lbs.njss.apps.individual.resume.dto.ResumeDTO" table="resume">

<id name="resumeID" unsaved-value="0">

<generator class="sequence">

<param name="sequence">SEQ_A_RESUMEID</param>

</generator>

</id>

<property name="userID" column="userid"/>

<property name="baseInfo" column="baseInfo"/>

<property name="intent" column="intent"/>

<property name="selfEvaluate" column="selfEvaluate"/>

<property name="educationLevel" column="educationLevel"/>

<property name="experience" column="experience"/>

<property name="certification" column="certification"/>

<property name="jobLetter" column="jobLetter"/>

<property name="addtionalInfo" column="addtionalInfo"/>

<property name="affix" column="affix" />

</class>

</hibernate-mapping>

这是对应的resume表:

SQL> desc resume

Name Type Nullable Default Comments

-------------- -------------- -------- ------- --------

RESUMEID NUMBER(10)

USERID VARCHAR2(10) Y

BASEINFO VARCHAR2(100) Y

INTENT VARCHAR2(50) Y

SELFEVALUATE VARCHAR2(100) Y

EDUCATIONLEVEL VARCHAR2(10) Y

EXPERIENCE VARCHAR2(200) Y

AFFIX VARCHAR2(100) Y

ADDTIONALINFO VARCHAR2(100) Y

JOBLETTER VARCHAR2(2000) Y

CERTIFICATION VARCHAR2(50) Y

chenkl
2003-09-02 10:35

// 在此输入java代码
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
    PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
  <class name="com.lbs.njss.apps.individual.resume.dto.ResumeDTO" table="resume">
    <id name="resumeID" unsaved-value="0">
      <generator class="sequence">
        <param name="sequence">SEQ_A_RESUMEID</param>
      </generator>
    </id>
    <property name="userID" column="userid"/>
    <property name="baseInfo" column="baseInfo"/>
    <property name="intent" column="intent"/>
    <property name="selfEvaluate" column="selfEvaluate"/>
    <property name="educationLevel" column="educationLevel"/>
    <property name="experience" column="experience"/>
    <property name="certification" column="certification"/>
    <property name="jobLetter" column="jobLetter"/>
    <property name="addtionalInfo" column="addtionalInfo"/>
    <property name="affix" column="affix" />
  </class>
</hibernate-mapping>
<p>

和resumeDTO对应的resume表:

SQL> desc resume

Name Type Nullable Default Comments

-------------- -------------- -------- ------- --------

RESUMEID NUMBER(10)

USERID VARCHAR2(10) Y

BASEINFO VARCHAR2(100) Y

INTENT VARCHAR2(50) Y

SELFEVALUATE VARCHAR2(100) Y

EDUCATIONLEVEL VARCHAR2(10) Y

EXPERIENCE VARCHAR2(200) Y

AFFIX VARCHAR2(100) Y

ADDTIONALINFO VARCHAR2(100) Y

JOBLETTER VARCHAR2(2000) Y

CERTIFICATION VARCHAR2(50) Y

猜你喜欢