錯(cuò)誤
c_grade?is?not?mapped?[from?c_grade//實(shí)體類
package?javabean;
//?Generated?2017-4-22?17:53:45?by?Hibernate?Tools?4.3.1.Final
import?javax.persistence.Column;
import?javax.persistence.Entity;
import?javax.persistence.FetchType;
import?javax.persistence.GeneratedValue;
import?static?javax.persistence.GenerationType.IDENTITY;
import?javax.persistence.Id;
import?javax.persistence.JoinColumn;
import?javax.persistence.ManyToOne;
import?javax.persistence.Table;
/**
?*?CGrade?generated?by?hbm2java
?*/
@Entity
@Table(name?=?"c_grade",?catalog?=?"credit_audit_system")
public?class?CGrade?implements?java.io.Serializable?{
private?Integer?gradeId;
private?CStudent?CStudent;
private?String?courseName;
private?Integer?grade;
public?CGrade()?{
}
public?CGrade(CStudent?CStudent,?String?courseName)?{
this.CStudent?=?CStudent;
this.courseName?=?courseName;
}
public?CGrade(CStudent?CStudent,?String?courseName,?Integer?grade)?{
this.CStudent?=?CStudent;
this.courseName?=?courseName;
this.grade?=?grade;
}
@Id
@GeneratedValue(strategy?=?IDENTITY)
@Column(name?=?"grade_id",?unique?=?true,?nullable?=?false)
public?Integer?getGradeId()?{
return?this.gradeId;
}
public?void?setGradeId(Integer?gradeId)?{
this.gradeId?=?gradeId;
}
@ManyToOne(fetch?=?FetchType.LAZY)
@JoinColumn(name?=?"student_id",?nullable?=?false)
public?CStudent?getCStudent()?{
return?this.CStudent;
}
public?void?setCStudent(CStudent?CStudent)?{
this.CStudent?=?CStudent;
}
@Column(name?=?"course_name",?nullable?=?false,?length?=?12)
public?String?getCourseName()?{
return?this.courseName;
}
public?void?setCourseName(String?courseName)?{
this.courseName?=?courseName;
}
@Column(name?=?"grade")
public?Integer?getGrade()?{
return?this.grade;
}
public?void?setGrade(Integer?grade)?{
this.grade?=?grade;
}
}//配置文件
<?xml?version="1.0"?encoding="UTF-8"?>??
<beans?xmlns="http://www.springframework.org/schema/beans"?xmlns:context="http://www.springframework.org/schema/context"?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns:tx="http://www.springframework.org/schema/tx"?xmlns:aop="http://www.springframework.org/schema/aop"?xsi:schemaLocation="??
http://www.springframework.org/schema/beans???
http://www.springframework.org/schema/beans/spring-beans-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/aop???
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd??
http://www.springframework.org/schema/context????
http://www.springframework.org/schema/context/spring-context-3.1.xsd???
">??
??
????<!--?JNDI(通過Tomcat)方式配置數(shù)據(jù)源?-->??
????<!--?<bean?id="dataSource"?class="org.springframework.jndi.JndiObjectFactoryBean">?<property?name="jndiName"?value="${jndiName}"></property>?</bean>?-->??
??????
??????
???????<!--?引入屬性文件?-->??
????<context:property-placeholder?location="classpath:config.properties"?/>??
????
??????
????<!--?配置數(shù)據(jù)源??這里class可以使用不同的驅(qū)動(dòng)-->??
????<bean?name="dataSource"?class="org.springframework.jdbc.datasource.DriverManagerDataSource">??
????????<property?name="url"?value="${jdbc_url}"?/>??
????????<property?name="username"?value="${jdbc_username}"?/>??
????????<property?name="password"?value="${jdbc_password}"?/>
????</bean>??
????
???
????<!--?配置hibernate?session工廠?-->??
????<bean?id="sessionFactory"?class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">??
????????<property?name="dataSource"?ref="dataSource"?/>??
????????<property?name="hibernateProperties">??
????????????<props>??
????????????????<prop?key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>??
????????????????<prop?key="hibernate.dialect">${hibernate.dialect}</prop>??
????????????????<prop?key="hibernate.show_sql">${hibernate.show_sql}</prop>??
????????????????<prop?key="hibernate.format_sql">${hibernate.format_sql}</prop>??
?????????????????<prop?key="current_session_context_class">thread</prop>????
?????????????????<prop?key="hibernate.connection.driver_class"?>${driverClassName}</prop>?
????????????</props>??
????????</property>??
??
????????<!--?自動(dòng)掃描注解方式配置的hibernate類文件?-->??
????????<property?name="packagesToScan">??
????????????<list>??
?????????????<!--?此處與entity實(shí)體路徑對(duì)應(yīng)?-->??
????????????????<value>javabean</value>??
????????????</list>??
????????</property>??
????</bean>??
????
????
??
????<!--?配置事務(wù)管理器?-->??
????<bean?name="transactionManager"?class="org.springframework.orm.hibernate4.HibernateTransactionManager">??
????????<property?name="sessionFactory"?ref="sessionFactory"></property>??
????</bean>????
??
??
????<!--?注解方式配置事物?-->??
????<tx:annotation-driven??transaction-manager="transactionManager"?/>???
??
??
</beans>
hibernate 查詢時(shí)報(bào)錯(cuò) is not mapped
qq_暗魔法天賜之子_03683319
2017-04-22 20:03:00