为了账号安全,请及时绑定邮箱和手机立即绑定

如何保持BLOB对象

- SQL Error: 17090, SQLState: null
- 不允许的操作: streams type cannot be used in batching
- Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [Students]
 at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2078)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
 at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
 at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
 at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
 at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
 at StudentsTest.tearDown(StudentsTest.java:34)
 at junit.framework.TestCase.runBare(TestCase.java:136)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run(TestCase.java:120)
 at junit.framework.TestSuite.runTest(TestSuite.java:230)
 at junit.framework.TestSuite.run(TestSuite.java:225)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: 不允许的操作: streams type cannot be used in batching
 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
 at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
 at oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedStatement.java:3775)
 at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:30)
 at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2062)
 ... 24 more


部分代码是这样写的

  InputStream input = new FileInputStream(file);
  byte[] byteArray = new byte[input.available()];
  input.read(byteArray);
  input.close();
  Students students = new Students("张三丰", "男", new Date(), "武当山");
  Blob pictrue = Hibernate.createBlob(byteArray);
 students.setPictrue(pictrue);
 System.out.println(students.getPictrue());
 session.save(students);

正在回答

3 回答

哦,我直接用的它给的jar包,就可以的。Blob pictrue = Hibernate.createBlob(byteArray);这里是不是应该传input进来呢?,因为图片文件在input里面。

0 回复 有任何疑惑可以回复我~

我也出错了难受

0 回复 有任何疑惑可以回复我~

兄弟,Hibernate.createBlob(byteArray);这个方法好像没有啊?可以通过编译?

0 回复 有任何疑惑可以回复我~
#1

car 提问者

有,是hibernate3.x的
2016-10-05 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

如何保持BLOB对象

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信