1 log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
2 log4j:WARN Please initialize the log4j system properly.
3 log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
4 Hibernate: insert into MYHR.IVAN.LOGIN (PASSWORD, USERNAME) values (?, ?)
5 用户信息保存成功!
6 Exception in thread "main" org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update 7 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
8 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
9 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
10 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
11 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
12 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
13 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
14 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
15 at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:366)
16 at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
17 at cn.pb.hibernate.dao.LoginDao.save(LoginDao.java:28)
18 at cn.pb.hibernate.test.Test.main(Test.java:18)
19 Caused by: java.sql.BatchUpdateException: ORA-00926: 缺失 VALUES 关键字
20
21 at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
22 at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10656)
23 at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
24 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
25 ... 9 more
这次用编写好的基础代码测试检查了好半天,数据库什么的都正常,就是报ORA-00926: 缺失 VALUES 关键字,网上没有靠谱的。发现在映射文件中schema="MYHR"很可疑,去掉MYHR问题还是依旧,最后直接把
schema="MYHR"删除,问题解决
1 <hibernate-mapping>
2 <class name="com.pb.hibernate.po.Login" table="IVAN.LOGIN" schema="MYHR">
3
4 <id name="userName" type="java.lang.String">
5 <column name="USERNAME" length="50" />
6 <generator class="assigned" />
7 </id>
8
9 <property name="passWord" type="java.lang.String">
10 <column name="PASSWORD" length="20" not-null="true" />
11 </property>
12
13 </class>
14 </hibernate-mapping>
|