SSH框架-Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement

昨晚修改了一些表关系,在相关的hbm.xml文件中做了改动,今天早上起来启动tomcat后,发现项目启动不了,控制台报错:

2015-6-14 9:09:42 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory‘ defined in class path resource [application-dao.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: column attribute may not be used together with <column> subelement
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
	at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
	at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
	at org.apache.catalina.core.StandardService.start(StandardService.java:525)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement
	at org.hibernate.cfg.HbmBinder.bindColumns(HbmBinder.java:1075)
	at org.hibernate.cfg.HbmBinder.bindColumnsOrFormula(HbmBinder.java:1547)
	at org.hibernate.cfg.HbmBinder.bindManyToOne(HbmBinder.java:1559)
	at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2090)
	at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)
	at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)
	at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
	at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
	at org.hibernate.cfg.Configuration.add(Configuration.java:716)
	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 39 more

为了解决这个问题,我又把昨晚改动过的hbm.xml文件恢复为原来的,再次启动发现没有报错,问题已经确定:hbm.xml文件配置问题。

看这个报错信息,应该是某个property属性的字段配置错了,于是我改过hbm.xml的文件一个个去核对,发现有一个XX.hbm.xml文件里面果然配置错了

如下:

        <!-- 用户表 ,多对一映射-->
        <many-to-one name="User" class="cn.test.web.pojo.User" column="user_id">
           <column name="user_id"></column>
        </many-to-one>

因为在配置many-to-one标签时,在 <many-to-one >标签这里既有column属性,也有column元素,明显是重复了,只需要配置一个colum即可!我把<column></column>去掉后,再重启tomcat,没有报错,问题解决!

时间: 2024-12-29 12:00:01

SSH框架-Caused by: org.hibernate.MappingException: column attribute may not be used together with <column> subelement的相关文章

ssh框架错误:org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role。

在做ssh项目练习的时候出现问题: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role 原因在于hibernate的懒加载出现的问题.在多方中的一方的配置没有指定加载方式,而且一方中的多方是懒加载,因此在获取一方的时候一方是获取到了,但是再获取多方的时候session已经关闭了,这时候会获取不到多方信息,因此报错. 解决办法: 将一方中的多方(one-to-many

ssh框架中spring整合hibernate的配置文件模板(带详细注释)

applicationContext.xml的配置文件模板 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans 3 xmlns="http://www.springframework.org/schema/beans" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xmlns:aop=&quo

Hibernate异常Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Set

一:异常截图 二:我的实体 @Entity @Table(name = "p_user") public class User extends AbstractEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; //账号 @Column(name = "account", nullable = true) private String account; /

org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert=&quot;false&quot; update=&quot;false&quot;)

Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com.boot.entity.RepEntity column: rep_batch (should be mapped with insert="false" update="false") at org.hibernate.mapping.PersistentClass.checkColumnDup

org.hibernate.MappingException: Could not determine type for: java.util.List, at table: user, for...

异常详情: Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: ss_user, for columns: [org.hibernate.mapping.Column(roles)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:336) ~[hibernate-core-4

SSH框架整合总结

SSH 框架为 Struts + Spring + Hibernate 的一个集成框架,是目前较流行的一种 web 应用程序开源框架. 集成SSH框架的系统从职责上分为四层:表示层.业务逻辑层.数据持久层和域模块层,以帮助开发人员在短期内搭建结构清晰.可复用性好.维护方便的Web应用程序.其中使用Struts作为系统的整体基础架构,负责MVC的分离,在Struts框架的模型部分,控制业务跳转,利用Hibernate框架对持久层提供支持,Spring做管理,管理struts和hibernate.具

ssh框架遇到的问题总结

1.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePro

org.hibernate.MappingException: An association from the table order_intem_inf refers to a unmapped

运行一个HIbernate的示例时出现如下错误信息 Exception in thread "main" java.lang.ExceptionInInitializerError at com.hibernate.utils.HibernateUtil.<clinit>(HibernateUtil.java:21) at org.hibernate.samples.PersonManager.main(PersonManager.java:23) Caused by: o

关于SSH框架设计的一些理解

最近在学习企业开发领域很流行的SSH框架(Struts.Hibernate.Spring),由于之前有做过原生的Servlet+JSP的项目,所以在学习过程中我会跟原生开发模式进行对比,在这里我把自己的一些理解做下小结. 1.Servlet+JSP原生开发 先简要说一下Java Web原生开发模式,Java Web开发通常是使用Tomcat之类的容器,Tomcat容器实现了一套也可以称为框架的东西,就是Servlet.Tomcat运行于Apache之类的Web服务器上,Apache服务器负责处理