hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误

出现这种错误是因为,实体类的配置文件(ClassName.hbm.xml)中的属性名和类中的属性名不一致造成的,检查并修改就可解决

比如:

类有如下属性:

private int id;

private String name;
private Department department;

配置文件:

<class name="Employee1">

<id name="id">
            <generator class="native"/>
        </id>

<property name="name"/>
        <many-to-one name="depart" column="depart_id"/>
    </class>

///////////////////////////

如上就会出现错误,因为多对一关系中的name的值depart和类的属性department没对应,就报错了

时间: 2024-10-07 01:36:31

hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误的相关文章

org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.Defau

出现org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.DefaultLoadEventListener.checkIdClass(DefaultLoadEvent

使用hibernate出现log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly.问题的解决办法

问题描述: log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).log4j:WARN Please initialize the log4j system properly. 问题分析: 大概意思就是它没读到log4j的配置信息,然后让你导入它什么的(差不多是这个意思,可能是你导入了,但没配置好) 解决方法: 从原因上分析,其实它是找不到它需要的那个名为log4j.pr

ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [object references an unsaved transient instance - save the transient instance before flushing: cn.itcast.domain.Custom

本片博文整理关于Hibernate中级联策略cascade和它导致的异常: Exception in thread "main" org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.mao.Address 关于这个异常应该是Hibernate初学者经常遇到的,导致

Hibernate ORM框架——续第一章:Java增删改查与Hibernate的增删改查的对比

一. 1)项目结构 2)SQL server 2008数据库的编写 create database Emp use Emp create table emp ( eno varchar(10), ename varchar(50), salary float ) insert into emp values('1','zss1',2000); insert into emp values('2','zss2',2000); update emp set ename='sss',salary=22

org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread spring集成Hibernate sessionfactory.getcurrentSession报错

sessionFactory.getCurrentSession()是要基于事务的,解决方法为在javaconfig配置类使用@EnableTransactionManagement注解  并且配置transactionManager bean. 在报错方法中使用@Transactional注解 原文地址:https://www.cnblogs.com/alexmason236/p/9767091.html

Spring MVC与Hibernate的整合

1.创建一个web项目. 2.引入类库. 3.配置中央处理器 <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 通过初始化参数指定springmvc配置文件的位置 --> <init-param> <

基于注解的Spring MVC整合Hibernate(所需jar包,spring和Hibernate整合配置,springMVC配置,重定向,批量删除)

1.导入jar watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdG90b3R1enVvcXVhbg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast"> 2.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version

基于注解的Spring MVC整合Hibernate

1.导入jar 2.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=&

Error creating bean with name &#39;sessionFactory&#39; defined in class path resource [applicationContext.xm

报错信息如下: <span style="font-size:24px;">17:18:32,245 ERROR ContextLoader:307 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resour