hibernate中的奇葩错误

调用hibernate中的原生方法save()方法

public void save(T t) throws HibernateException {
getSession().save(t);
}

 

但是还是报错

 

Hibernate: 

    insert 
    into
        barshop.product
        (product_type, store_product, product_number, product_name, pop_price, hon_price, vip_price, sale, hot, photo, existed, describe, content) 
    values
        (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[WARN ] method:org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:144)
SQL Error: 1064, SQLState: 42000
[ERROR] method:org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logExceptions(SqlExceptionHelper.java:146)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'describe, content) values (1, 1, '001', '1号产品', 150, 50, 80, 5.02, 50, 'ph' at line 1
[WARN ] method:org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler.logWarning(SqlExceptionHelper.java:232)
SQL Warning Code: 1064, SQLState: 42000
[WARN ] method:org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler.logWarning(SqlExceptionHelper.java:233)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'describe, content) values (1, 1, '001', '1号产品', 150, 50, 80, 5.02, 50, 'ph' at line 1
[ERROR] method:com.atgeretg.barShop.service.impl.BaseServiceImpl.save(BaseServiceImpl.java:104)
HibernateException error
org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:80)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:96)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:58)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3032)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3558)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:98)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:492)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:197)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:181)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:216)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:334)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:289)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:195)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)

at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702)

 

这个错很奇葩吧,我找了一下午才发现,我用了mysql中的关键字describe,看这句(product_type, store_product, product_number, product_name, pop_price, hon_price, vip_price, sale, hot, photo, existed,describe, content) 

所以一直报错...........

报错时,发现自己代码没错,看看有没有用到什么关键字之类的,也许可以解决.

 

如果您在编写java过程中有出现问题,如果不嫌弃小编我学历浅薄,欢迎添加我的微信一起讨论,感谢您的支持!微信号:atgeretg
大神您觉得还可以的话请您打赏,您的十分满意是小编的无限动力。

 

 

你可能感兴趣的:(web,jsp)