为了账号安全,请及时绑定邮箱和手机立即绑定

hibernate 查询时报错 is not mapped

hibernate 查询时报错 is not mapped

错误 c_grade is not mapped [from c_grade//实体类 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)方式配置数据源 -->       <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jndiName}"></property> </bean> -->                        <!-- 引入属性文件 -->       <context:property-placeholder location="classpath:config.properties" />                   <!-- 配置数据源  这里class可以使用不同的驱动-->       <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>              <!-- 自动扫描注解方式配置的hibernate类文件 -->           <property name="packagesToScan">               <list>                <!-- 此处与entity实体路径对应 -->                   <value>javabean</value>               </list>           </property>       </bean>                    <!-- 配置事务管理器 -->       <bean name="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">           <property name="sessionFactory" ref="sessionFactory"></property>       </bean>               <!-- 注解方式配置事物 -->       <tx:annotation-driven  transaction-manager="transactionManager" />          </beans>
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 2610 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信