applicationcontext.xml
<?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:aop="http://www.springframework.org/schema/aop"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           
     <context:annotation-config/>
   <!--   <context:property-placeholder location="classpath:dataSourse.property"/> -->
     <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
      <list>
<value>classpath:/jdbc.property</value>     
      </list>
      </property>
     </bean>
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="${jdbc.driverClassName}"></property>
      <property name="url" value="${jdbc.url}"></property>
      <property name="username" value="${jdbc.username}"></property>
      <property name="password" value="${jdbc.password}"></property>
     </bean>
     
     <bean id="sessionFactoyr" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      <property name="dataSource" ref="dataSource"></property>
      <property name="hibernateProperties">
      <props>
      <prop key="hibernate.sql_show">true</prop>
      <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
      </props>
      </property>
       <property name="packagesToScan" value="com.entity"/>
     </bean>
     
     <bean id="dao" class="com.dao.daoImpl"></bean>
     <bean id="textAction" class="com.action.Action"></bean>
</beans>entity类
package com.entity;import java.io.Serializable;import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
@Entity
@IdClass(PK.class)
public class Sc implements Serializable{ private double score;

private String sno;
private String cno;
@Id
public String getCno() {
return cno;
}
public void setCno(String cno) {
this.cno = cno;
}
@Id
public String getSno() {
return sno;
}
public void setSno(String sno) {
this.sno = sno;
}


public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}


}
联合主键类:
package com.entity;import java.io.Serializable;public class PK implements Serializable { private String con;
private String sno;
public String getCon() {
return con;
}
public void setCon(String con) {
this.con = con;
}
public String getSno() {
return sno;
}
public void setSno(String sno) {
this.sno = sno;
}

@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
return super.equals(obj);
}

@Override
public int hashCode() {
// TODO Auto-generated method stub
return super.hashCode();
}
}
这个异常怎么回事呀,百度一下也没发现有几个这个异常的问题

解决方案 »

  1.   

    @IdClass里的属性要和pk一致才行,你一个cno,一个con,当然报错了。
      

  2.   

    他没找到你的主键啊你在Sc里面应该用PK这个主键吧异常的意思是说,你@IdClass指定的那个类在Sc里没有出现
      

  3.   

    刚刚也发现了 但是改了之后肯定哪里还是存在的,不然会包con干嘛,好好检查。
      

  4.   

    刚刚也发现了 但是改了之后肯定哪里还是存在的,不然会包con干嘛,好好检查。在com.entity.sc类中搜索一下确实没有啊,但是他怎么会提示在sc类里面有con呢
      

  5.   

    刚刚也发现了 但是改了之后肯定哪里还是存在的,不然会包con干嘛,好好检查。- -确实存在在PK里面 谢谢你