晕死,有人见过类似的错误没?关于的hibernate的

我没分了 5.........
先来错误提示(首先说明不是简单的表不存在,所有的映射文件都没有映射过company表[至少没有显式引用])

[code="java"]ERROR 2009-09-10 13:31:58.343 JDBCExceptionReporter:logExceptions - Table 'bfw_utf8.company' doesn't exist
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: could not insert: [com.bafang.pojos.SiteAd]; bad SQL grammar [insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist
Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Table 'bfw_utf8.company' doesn't exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1160)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:685)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1400)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1314)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1299)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:73)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:33)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:598)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:358)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:595)
at com.bafang.pojos.base._BaseRootDAO.save(_BaseRootDAO.java:25)
at com.bafang.pojos.base.BaseSiteAdDAO.save(BaseSiteAdDAO.java:20)
at com.bafang.pojos.base.BaseSiteAdDAO$$FastClassByCGLIB$$33c630a7.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:609)
at com.bafang.pojos.dao.SiteAdDAO$$EnhancerByCGLIB$$29bf5095.save()
at com.bafang.web.action.admin.main.AdAction.add(AdAction.java:107)
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.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at com.bafang.web.servlet.BFActionServlet.process(BFActionServlet.java:26)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.bafang.web.filters.HTMLFilter.synthesisURI(HTMLFilter.java:85)
at com.bafang.web.filters.HTMLFilter.doFilter(HTMLFilter.java:60)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.bafang.web.filters.AdminFilter.doFilter(AdminFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.bafang.web.filters.SubsiteFilter.doFilter(SubsiteFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:619)[/code]

相关hibernate映射文件
SiteAd.hbm.xml
[code="xml"]<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >








    <many-to-one name="siteAdLocation" column="site_ad_location_id" class="SiteAdLocation" not-null="false" insert="false" update="false" />
    <property name="siteAdKeywordId" column="site_ad_keyword_id" type="integer" not-null="false" length="11" />
    <property name="siteAdKeyword" column="site_ad_keyword" type="string" not-null="false" length="255" />

    <property name="companyId" column="company_id" type="integer" not-null="false" length="11" />
    <property name="companyName" column="company_name" type="string" not-null="false" length="255" />
    <!--<many-to-one name="company" column="company_id" class="Store" not-null="false" insert="false" update="false" />-->
    <property name="txt" column="txt" type="string" not-null="false" length="255" />
    <property name="url" column="url" type="string" not-null="false" length="255" />
    <property name="mediaType" column="media_type" type="string" not-null="false" length="255" />
    <property name="mediaFile" column="media_file" type="string" not-null="false" length="255" />
    <property name="type" column="type" type="string" not-null="false" length="100" />
    <property name="charge" column="charge" type="java.lang.Float" not-null="false" length="12" />
    <property name="startTime" column="start_time" type="timestamp" not-null="false" length="19" />
    <property name="endTime" column="end_time" type="timestamp" not-null="false" length="19" />
    <property name="itemOrder" column="item_order" type="integer" not-null="false" length="11" />
    <property name="enabled" column="enabled" type="boolean" not-null="false" length="1" />
</class>

[/code]
pojo相关类
com.bafang.pojos.SiteAd.java
[code="java"]package com.bafang.pojos;

import com.bafang.pojos.base.BaseSiteAd;

public class SiteAd extends BaseSiteAd {

private static final long serialVersionUID = 7092206885096359130L;

public SiteAd () {
}

public String getTypeName(){
    if("1".equals(getType()))
        return "多媒体广告";
    else if("2".equals(getType()))
        return "连接广告";
    else if("3".equals(getType()))
        return "店铺广告";
    else if("4".equals(getType()))
        return "店铺评论广告";
    else
        return "其它广告";

}

}[/code]
com.bafang.pojos.base.BaseSiteAd.java
[code="java"]package com.bafang.pojos.base;

import java.io.Serializable;

public abstract class BaseSiteAd implements Serializable {

protected Integer id;

protected Integer subsiteId;
protected String siteAdLocationId;
protected String siteAdLocationName;
protected Integer siteAdKeywordId;
protected String siteAdKeyword;
protected Integer companyId;
protected String companyName;
protected String txt;
protected String url;
protected String mediaType;
protected String mediaFile;
protected String type;
protected Float charge;
protected java.util.Date startTime;
protected java.util.Date endTime;
protected Integer itemOrder;
protected Boolean enabled;

protected com.bafang.pojos.SiteAdLocation siteAdLocation;

public Integer getId() {
    return id;
}

public void setId(Integer id) {
    this.id = id;
}

public Integer getSubsiteId() {
    return subsiteId;
}

public void setSubsiteId(Integer subsiteId) {
    this.subsiteId = subsiteId;
}

public String getSiteAdLocationId() {
    return siteAdLocationId;
}

public void setSiteAdLocationId(String siteAdLocationId) {
    this.siteAdLocationId = siteAdLocationId;
}

public String getSiteAdLocationName() {
    return siteAdLocationName;
}

public void setSiteAdLocationName(String siteAdLocationName) {
    this.siteAdLocationName = siteAdLocationName;
}

public Integer getSiteAdKeywordId() {
    return siteAdKeywordId;
}

public void setSiteAdKeywordId(Integer siteAdKeywordId) {
    this.siteAdKeywordId = siteAdKeywordId;
}

public String getSiteAdKeyword() {
    return siteAdKeyword;
}

public void setSiteAdKeyword(String siteAdKeyword) {
    this.siteAdKeyword = siteAdKeyword;
}

public Integer getCompanyId() {
    return companyId;
}

public void setCompanyId(Integer companyId) {
    this.companyId = companyId;
}

public String getCompanyName() {
    return companyName;
}

public void setCompanyName(String companyName) {
    this.companyName = companyName;
}

public String getTxt() {
    return txt;
}

public void setTxt(String txt) {
    this.txt = txt;
}

public String getUrl() {
    return url;
}

public void setUrl(String url) {
    this.url = url;
}

public String getMediaType() {
    return mediaType;
}

public void setMediaType(String mediaType) {
    this.mediaType = mediaType;
}

public String getMediaFile() {
    return mediaFile;
}

public void setMediaFile(String mediaFile) {
    this.mediaFile = mediaFile;
}

public String getType() {
    return type;
}

public void setType(String type) {
    this.type = type;
}

public Float getCharge() {
    return charge;
}

public void setCharge(Float charge) {
    this.charge = charge;
}

public java.util.Date getStartTime() {
    return startTime;
}

public void setStartTime(java.util.Date startTime) {
    this.startTime = startTime;
}

public java.util.Date getEndTime() {
    return endTime;
}

public void setEndTime(java.util.Date endTime) {
    this.endTime = endTime;
}

public Integer getItemOrder() {
    return itemOrder;
}

public void setItemOrder(Integer itemOrder) {
    this.itemOrder = itemOrder;
}

public Boolean getEnabled() {
    return enabled;
}

public void setEnabled(Boolean enabled) {
    this.enabled = enabled;
}

public com.bafang.pojos.SiteAdLocation getSiteAdLocation() {
    return siteAdLocation;
}

public void setSiteAdLocation(com.bafang.pojos.SiteAdLocation siteAdLocation) {
    this.siteAdLocation = siteAdLocation;
}

}[/code]
保存动作是直接调用spring的工具类
org.springframework.orm.hibernate3.support.HibernateDaoSupport.save(Object obj);
我debug过,就是保存的动作后报的错
数据库query 日志
[code="java"]090910 13:31:50 2 Query SET autocommit=0
2 Prepare select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit ?
2 Execute select siteadloca0_.id as id17_, siteadloca0_.subsite_id as subsite2_17_, siteadloca0_.name as name17_, siteadloca0_.type as type17_, siteadloca0_.width as width17_, siteadloca0_.height as height17_, siteadloca0_.item_count as item7_17_, siteadloca0_.url as url17_, siteadloca0_.enabled as enabled17_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1 limit 20
2 Close stmt

2 Query commit
2 Query SET autocommit=1
2 Query SET autocommit=0
2 Prepare select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=?
2 Execute select count(*) as col_0_0_ from site_ad_location siteadloca0_ where 1=1 and siteadloca0_.subsite_id=1
2 Close stmt

2 Query commit
2 Query SET autocommit=1
090910 13:31:58 2 Prepare insert into site_ad (subsite_id, site_ad_location_id, site_ad_location_name, site_ad_keyword_id, site_ad_keyword, company_id, company_name, txt, url, media_type, media_file, type, charge, start_time, end_time, item_order, enabled) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2 Query select name into str from site_ad_location where id=new.site_ad_location_id
2 Query select name into str from company where id=new.company_id
2 Query SELECT 1
2 Close stmt

D:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld, Version: 5.1.37-community-log (MySQL Community Server (GPL)). started with:
TCP Port: 3306, Named Pipe: (null)
Time Id Command Argument
090910 13:33:15 1 Connect root@localhost on
1 Query SET NAMES utf8
2 Connect root@localhost on
2 Query SELECT @@sql_mode
2 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
2 Query SET NAMES utf8
2 Quit

090910 13:33:17 1 Quit

3 Connect root@localhost on
3 Query SELECT @@sql_mode
3 Query SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
3 Query SET NAMES utf8[/code]

[b]问题补充:[/b]
[quote]dwangel[/quote]已经清理过项目 还是一样
谢谢啊 已经找到问题了
以前写成的程序员 弄了个触发器在数据库里
刚刚发现的
谢谢了 分不多都给你了

1个回答

看文件,你是原来声明过company,然后 注释掉了。

检查一下,是否有重复的映射文件,而 运行时,实际是那个没注释掉的文件。

如果是放classpath ,clean下project

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐