无法执行JDBC批量更新错误

时间:2013-06-08 21:57:14

标签: hibernate

我遇到了Hibernate的问题。当我尝试将一些日期放入基地时,我收到此错误:

>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
>SLF4J: Defaulting to no-operation (NOP) logger implementation
>SLF4J: See `http://www.slf4j.org/codes.html#StaticLoggerBinder` for further details.
>Hibernate: select nextval ('hibernate_sequence')
>Hibernate: insert into Faculty (Faculty Name, FacID) values (?, ?)
>Exception in thread "AWT-EventQueue-0" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch >update
>       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
>   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
>   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
>   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
>   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
>   at >org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
>   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
>   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
>   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
>   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
>   at org.magda.hibernate.HibernateTest.Add(HibernateTest.java:16)
>   at DziekanatProjekt.AddObjectsToBase.AddFac(AddObjectsToBase.java:11)
>   at DziekanatProjekt.Administrator.doneMouseClicked(Administrator.java:184)
>   at DziekanatProjekt.Administrator.access$1(Administrator.java:177)
>   at DziekanatProjekt.Administrator$3.mouseClicked(Administrator.java:112)
>   at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
>   at java.awt.Component.processMouseEvent(Unknown Source)
>   at javax.swing.JComponent.processMouseEvent(Unknown Source)
>   at java.awt.Component.processEvent(Unknown Source)
>   at java.awt.Container.processEvent(Unknown Source)
>   at java.awt.Component.dispatchEventImpl(Unknown Source)
>   at java.awt.Container.dispatchEventImpl(Unknown Source)
>   at java.awt.Component.dispatchEvent(Unknown Source)
>   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
>   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>   at java.awt.Container.dispatchEventImpl(Unknown Source)
>   at java.awt.Window.dispatchEventImpl(Unknown Source)
>   at java.awt.Component.dispatchEvent(Unknown Source)
>   at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>   at java.awt.EventQueue.access$200(Unknown Source)
>   at java.awt.EventQueue$3.run(Unknown Source)
>   at java.awt.EventQueue$3.run(Unknown Source)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>   at java.awt.EventQueue$4.run(Unknown Source)
>   at java.awt.EventQueue$4.run(Unknown Source)
>   at java.security.AccessController.doPrivileged(Native Method)
>   at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>   at java.awt.EventQueue.dispatchEvent(Unknown Source)
>   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>   at java.awt.EventDispatchThread.run(Unknown Source)
>Caused by: java.sql.BatchUpdateException: Zadanie wsadowe 0 insert into Faculty (Faculty Name, FacID) values ('Informatyka', 1) zostało przerwane. Wywołaj getNextException by poznać przyczynę.
>   at >org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2746)
>   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1887)
>   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:405)
>   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2893)
>   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
>   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
>   ... 44 more

这是我的班级:

>@Entity
>@Table(name = "Faculty")
>public class Faculty implements Serializable {
>   
>   private static final long serialVersionUID = 1L;
>
>   @Id
>   @GeneratedValue(strategy = GenerationType.AUTO)
>   private int FacID;
>   
>   @Column(name = "Faculty Name")
>   private String facName;
>   
>   public Faculty(){};
>   
>   public Faculty(String name){
>       this.facName = name;
>   }
>   public String getFacName() {
>       return facName;
>   }
>
>   public void setFacName(String facName) {
>       this.facName = facName;
>   }
>   public int getFacID() {
>       return FacID;
>   }
>
>   public void setFacID(int facID) {
>       FacID = facID;
>   }
>}

我尝试了很多解决方案,但没有任何效果。你知道我需要做什么来运行它吗?请帮忙。

1 个答案:

答案 0 :(得分:0)

重命名列名Faculty Name,删除两个单词之间的空格,例如FacultyName