Announcement Announcement Module
Collapse
No announcement yet.
Insert TIFF as BLOB in Oracle fails, how can I configure OracleLobHandler in JPA? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Insert TIFF as BLOB in Oracle fails, how can I configure OracleLobHandler in JPA?

    Hello,

    I want to store/load TIFF images using a BLOB column in Oracle (9i, I think) but it doesn't work: "java.sql.SQLException: operación no permitida: streams type cannot be used in batching"

    I've created the project using Roo 1.2 and I'd like to know how can I configure JPA in order to manage the BLOBs for Oracle.

    Or any other alternative that fits well in a Spring project.

    Thank you very much.
    Javier.

    ADDITIONAL INFO:
    • The integration tests succeed, but code with an actual TIFF image doesn't work

    Having the Entity:

    Code:
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord(identifierColumn = "ID_IMAGEN", table = "T_IMAGEN", versionField = "")
    public class Imagen {
    
    //...
    
        @NotNull
        @Column(name = "IMAGEN")
        @Lob
        @Basic(fetch = FetchType.LAZY)
        private byte[] image;
    
        @Column(name = "TIPO_MIME")
        @Size(max = 50)
        private String mimeType;
    
        @Column(name = "NUMERO_PAGINAS")
        @Max(99L)
        private Integer pagesNumber;
    
    //...
    Roo builds a DataOnDemand that uses a String to fill the byte[] field:

    Code:
    privileged aspect ImagenDataOnDemand_Roo_DataOnDemand { 
    
        public void ImagenEscanerDataOnDemand.setImage(Imagen obj, int index) {
            byte[] imagen = String.valueOf(index).getBytes();
            obj.setImagen(imagen);
        }
    But my code (I put it in the integration test) doesn't work:

    Code:
    @RooIntegrationTest(entity = Imagen.class, findAll=false)
    public class ImagenIntegrationTest {
    
        @Autowired
        //Yepes, "pushed in".
        private ImagenDataOnDemand dod;
    
    	@Test
    	public void testSaveImage() throws IOException {
    
    		Imagen imagen = dod.getNewTransientImagen(Integer.MAX_VALUE);
    		
    		bytes = FileUtils.readFileToByteArray("src/test/resources/images/tiff.tiff");
    		imagenEscaner.setImagen(bytes);
    		
    		imagenEscaner.persist();
    		imagenEscaner.flush();
    
    	}
    • I'm not the only one with that problem

    More than a year ago, eleonhardo made the same question: How to configure OracleLobHandler in ROO/JPA
    • Yes, I tried the Jose Delgado's tutorial (AKA delgad9 or JD)

    The instructions from Spring Roo: Saving/Retreving BLOB object in Spring Roo works well with MySQL, and even for PostgreSQL (if you take care of retrieving the data in a transaction due to the way PostgreSQL manages "big data") and even from both DBMS (lot of fun here, because you need to configure the DB separately. The next step would be to use JTA)
    • Finally, I know there are problems managing BLOBs in Oracle, but the only solutions I found are related to Hibernate or plain JDBC.

    According OracleLobHandler (See also LobHandler) Oracle uses "its own proprietary BLOB/CLOB API"

    I've found instructions for configuring OracleLobHandler in Hibernate.

    To change the driver or the Oracle version (it could be a solution) is not an option for the time being, it depends on the Production department.

    Alternatively, I could use plain JDBC, as it's explained in the manual: 13.7.2 Handling BLOB and CLOB objects

    But I'd rather to use JPA, since it's totally configured thanks to Roo.

    This is what I want, and that is the reason for this looooooooooooooong question.

    Thank you very much for reading that.

    J.

  • #2
    It seems I made a very extensive POST for a simple question:

    How can I store a TIFF image in a BLOB Column in Oracle? The code created with Roo that works for MySQL and PostgreSQL, doesn't work for Oracle 8.1 (not Oracle 9, as I said before)

    Comment


    • #3
      Dear (b)log:

      First attempt: failure.

      applicationContext.xml
      Code:
          <bean class="org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor" id="nativeJdbcExtractor" />
          
          <bean class="org.springframework.jdbc.support.lob.OracleLobHandler" id="lobHandler">
          	<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
          </bean>
      Entity:
      Code:
      public class Imagen {
      
          @Transactional
          public void save() {
              if (this.entityManager == null) this.entityManager = entityManager();
              this.entityManager.getEntityManagerFactory().getProperties().put("lobHandler", this.lobHandler);
              this.entityManager.persist(this);
          }
      Test:
      Code:
      public class ImagenIntegrationTest {
      
      		//Imagen.persist();
      		Imagen.save();
      		
              
          }
      ERROR:
      java.lang.UnsupportedOperationException
      at java.util.Collections$UnmodifiableMap.put(Collecti ons.java:1301)
      at com.malsolo.blobs.domain.Imagen.save(Imagen.java:1 02)
      at com.malsolo.blobs.domain.ImagenIntegrationTest.tes tSaveImageForGi(ImagenIntegrationTest.java:87)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:618)
      at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
      at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
      at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:83)
      at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
      at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:48)
      at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
      at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
      at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
      at org.junit.runners.ParentRunner.run(ParentRunner.ja va:292)
      at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
      at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)

      Comment


      • #4
        Second attempt: failure

        applicationContext.xml
        Code:
            <bean class="org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtractor" id="nativeJdbcExtractor" />
            
            <bean class="org.springframework.jdbc.support.lob.OracleLobHandler" id="lobHandler">
            	<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
            </bean>
        
            <bean class="org.springframework.jdbc.core.JdbcTemplate" id="jdbcTemplate">
            	<property name="dataSource" ref="dataSource" />
            </bean>
        Entity:
        Code:
        public class Imagen {
        
            @Transactional
            public void save() {
                jdbcTemplate.execute("insert into gi_imagen_escaner "
        	        + " (alto, ancho, fecha_alta, datos, ... ) "
        	        + " values (?, ?, ?, ?, ...) "
                	,
                	new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
        				
        				@Override
        				protected void setValues(PreparedStatement ps, LobCreator lobCreator)
        						throws SQLException, DataAccessException {
        					
        					ps.setInt(1, Imagen.this.alto);
        					ps.setInt(2, Imagen.this.ancho);
        					ps.setDate(3, new java.sql.Date(Imagen.this.fechaAlta.getTime()));
        					lobCreator.setBlobAsBytes(ps, 5, Imagen.this.imagen);
        					...
        				}
        			}
                );
            }
        Test:
        Code:
        public class ImagenIntegrationTest {
        
        		//Imagen.persist();
        		Imagen.save();
        ERROR
        java.lang.NoSuchMethodError: java/sql/Connection.unwrap(Ljava/lang/ClassLjava/lang/Object;
        at org.springframework.jdbc.support.nativejdbc.Jdbc4N ativeJdbcExtractor.doGetNativeConnection(Jdbc4Nati veJdbcExtractor.java:98)
        at org.springframework.jdbc.support.nativejdbc.Native JdbcExtractorAdapter.getNativeConnection(NativeJdb cExtractorAdapter.java:99)
        at org.springframework.jdbc.support.nativejdbc.Native JdbcExtractorAdapter.getNativeConnectionFromStatem ent(NativeJdbcExtractorAdapter.java:135)
        at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.getOracleConnection(OracleLob Handler.java:527)
        at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.createLob(OracleLobHandler.ja va:486)
        at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.setBlobAsBytes(OracleLobHandl er.java:368)
        at com.malsolo.blobs.domain.Imagen$1.setValues(Imagen .java:129)
        at org.springframework.jdbc.core.support.AbstractLobC reatingPreparedStatementCallback.doInPreparedState ment(AbstractLobCreatingPreparedStatementCallback. java:72)
        at org.springframework.jdbc.core.support.AbstractLobC reatingPreparedStatementCallback.doInPreparedState ment(AbstractLobCreatingPreparedStatementCallback. java:1)
        at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:587)
        at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:615)
        at com.malsolo.blobs.domain.Imagen.save(Imagen.java:1 14)
        at com.malsolo.blobs.domain.ImagenIntegrationTest.tes tSaveImageForGi(ImagenIntegrationTest.java:87)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:618)
        at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
        at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
        at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
        at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
        at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
        at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:83)
        at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:48)
        at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
        at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
        at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
        at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
        at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
        at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
        at org.junit.runners.ParentRunner.run(ParentRunner.ja va:292)
        at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
        at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)


        That's true for the JAR that I'm using

        Comment


        • #5
          Third attempt: failure

          SimpleNativeJdbcExtractor instead of OracleJdbc4NativeJdbcExtractor

          applicationContext.xml

          Code:
              <bean class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" id="nativeJdbcExtractor" />
          ERROR
          org.springframework.dao.InvalidDataAccessApiUsageE xception: OracleLobCreator needs to work on [oracle.jdbc.OracleConnection], not on [org.apache.commons.dbcp.PoolableConnection]: specify a corresponding NativeJdbcExtractor; nested exception is java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection incompatible with oracle.jdbc.OracleConnection
          at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.createLob(OracleLobHandler.ja va:505)
          at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.setBlobAsBytes(OracleLobHandl er.java:368)
          at com.malsolo.blobs.domain.Imagen$1.setValues(Imagen .java:129)
          at org.springframework.jdbc.core.support.AbstractLobC reatingPreparedStatementCallback.doInPreparedState ment(AbstractLobCreatingPreparedStatementCallback. java:72)
          at org.springframework.jdbc.core.support.AbstractLobC reatingPreparedStatementCallback.doInPreparedState ment(AbstractLobCreatingPreparedStatementCallback. java:1)
          at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:587)
          at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:615)
          at com.malsolo.blobs.domain.Imagen.save(Imagen.java:1 14)
          at com.malsolo.blobs.domain.ImagenIntegrationTest.tes tSaveImageForGi(ImagenIntegrationTest.java:87)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:618)
          at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:44)
          at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
          at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:41)
          at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
          at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
          at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:83)
          at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
          at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:48)
          at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
          at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
          at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
          at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
          at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
          at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
          at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
          at org.junit.runners.ParentRunner.run(ParentRunner.ja va:292)
          at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
          at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
          at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
          Caused by: java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection incompatible with oracle.jdbc.OracleConnection
          at oracle.jdbc.driver.OracleConnection.physicalConnec tionWithin(OracleConnection.java:5041)
          at oracle.sql.BLOB.createTemporary(BLOB.java:767)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:618)
          at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.prepareLob(OracleLobHandler.j ava:541)
          at org.springframework.jdbc.support.lob.OracleLobHand ler$OracleLobCreator.createLob(OracleLobHandler.ja va:488)
          ... 36 more

          Comment


          • #6
            Fourth attempt: success?

            applicationContext.xml
            Code:
            <bean class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" id="nativeJdbcExtractor" />
            Bibliography:

            java2s.com: 28.43.1.Use Lob Handler To Handle Large Chunk of Data

            java2s.com: Insert Clob Data

            java2s.com: 28.43.2.Deal With Binary Stream With Lob Handler

            java2s.com: Insert Clob Data

            Spring framework reference: 13.7.2 Handling BLOB and CLOB objects

            Comment


            • #7
              Now my question is, is that approach correct?

              This application will be deployed in WebSphere, so I'm not sure of what I'm doing :'(

              Comment


              • #8
                @jbbarquero,

                I removed my previous blog since you pretty much resolved your issue...

                Thank you for using my stuff. I am glad it is working for you. Thanks for mentioned it too.

                Roogards
                jD
                Last edited by delgad9; Feb 10th, 2012, 01:34 PM.

                Comment


                • #9
                  You're welcome @delgad9.

                  Regarding Oracle, I can't wait *to hear about "upgrading offers". I don't want either.

                  Besides, I'm used to working with DB2 and I'm not a fan of Oracle (it's only a matter of habit)

                  Maybe I'll post this question to the Spring Data project. With some luck, they have solved this problem in their Oracle project.

                  Thank you very much.

                  Javier.

                  Comment


                  • #10
                    UPDATE: I've try with Blob instead of bytes but it doesn't work either:

                    2012-02-22 16:54:58,260 [main] DEBUG org.hibernate.SQL -
                    insert
                    into
                    TABLE
                    (COLUMNS...)
                    values
                    (?, ...)
                    Hibernate:
                    insert
                    into
                    TABLE
                    (COLUMNS...)
                    values
                    (?, ...)
                    2012-02-22 16:54:58,265 [main] INFO org.hibernate.type.descriptor.java.DataHelper - Could not locate 'java.sql.NClob' class; assuming JDBC 3
                    2012-02-22 16:54:58,266 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
                    2012-02-22 16:54:58,273 [main] DEBUG org.hibernate.util.JDBCExceptionReporter - could not insert: [com.malsolo.domain.Image] [insert into TABLE (COLUMNS...) values (?, ...)]
                    java.sql.SQLException: operación no permitida: streams type cannot be used in batching
                    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
                    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
                    at oracle.jdbc.driver.OraclePreparedStatement.addBatc h(OraclePreparedStatement.java:3775)
                    at org.apache.commons.dbcp.DelegatingPreparedStatemen t.addBatch(DelegatingPreparedStatement.java:175)
                    at org.apache.commons.dbcp.DelegatingPreparedStatemen t.addBatch(DelegatingPreparedStatement.java:175)
                    at org.hibernate.jdbc.BatchingBatcher.addToBatch(Batc hingBatcher.java:53)
                    at org.hibernate.persister.entity.AbstractEntityPersi ster.insert(AbstractEntityPersister.java:2434)
                    at org.hibernate.persister.entity.AbstractEntityPersi ster.insert(AbstractEntityPersister.java:2874)
                    at org.hibernate.action.EntityInsertAction.execute(En tityInsertAction.java:79)
                    at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:273)
                    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:265)
                    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:184)
                    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:321)
                    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:51)
                    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:1216)
                    at org.hibernate.ejb.AbstractEntityManagerImpl.flush( AbstractEntityManagerImpl.java:960)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
                    at java.lang.reflect.Method.invoke(Method.java:618)
                    at org.springframework.orm.jpa.SharedEntityManagerCre ator$SharedEntityManagerInvocationHandler.invoke(S haredEntityManagerCreator.java:240)
                    at $Proxy41.flush(Unknown Source)
                    at com.malsolo.domain.Image_Roo_Jpa_ActiveRecord.ajc$ interMethod$com_malsolo_domain_Image_Roo_Jpa_Activ eRecord$com_malsolo_domain_Image$flush(Image_Roo_J pa_ActiveRecord.aj:60)
                    at com.malsolo.domain.Image.flush(Image.java:1)
                    at com.malsolo.domain.Image_Roo_Jpa_ActiveRecord.ajc$ interMethodDispatch1$com_malsolo_domain_Image_Roo_ Jpa_ActiveRecord$com_malsolo_domain_Image$flush(Im age_Roo_Jpa_ActiveRecord.aj)
                    at com.malsolo.domain.ImageIntegrationTest.testSaveAc tualTiffImage(ImageIntegrationTest.java:63)
                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
                    at java.lang.reflect.Method.invoke(Method.java:618)
                    at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:45)
                    at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
                    at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:42)
                    at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
                    at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
                    at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:83)
                    at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
                    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
                    at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:47)
                    at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
                    at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
                    at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
                    at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
                    at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
                    at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
                    at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
                    at org.junit.runners.ParentRunner.run(ParentRunner.ja va:300)
                    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
                    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
                    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
                    2012-02-22 16:54:58,274 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 17090, SQLState: null
                    2012-02-22 16:54:58,274 [main] ERROR org.hibernate.util.JDBCExceptionReporter - operación no permitida: streams type cannot be used in batching
                    2012-02-22 16:54:58,275 [main] DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - mark transaction for rollback

                    Comment


                    • #11
                      With bytes[], the error is very similar:

                      2012-02-22 17:12:30,367 [main] DEBUG org.hibernate.SQL -
                      insert
                      into
                      TABLE
                      (COLUMNS...)
                      values
                      (?, ...)
                      Hibernate:
                      insert
                      into
                      TABLE
                      (COLUMNS...)
                      values
                      (?, ...)
                      2012-02-22 17:12:30,382 [main] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
                      2012-02-22 17:12:30,382 [main] DEBUG org.hibernate.util.JDBCExceptionReporter - could not insert: [com.malsolo.domain.Image] [insert into TABLE (COLUMNS...) values (?, ...)]
                      java.sql.SQLException: operación no permitida: streams type cannot be used in batching
                      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
                      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
                      at oracle.jdbc.driver.OraclePreparedStatement.addBatc h(OraclePreparedStatement.java:4236)
                      at org.apache.commons.dbcp.DelegatingPreparedStatemen t.addBatch(DelegatingPreparedStatement.java:175)
                      at org.apache.commons.dbcp.DelegatingPreparedStatemen t.addBatch(DelegatingPreparedStatement.java:175)
                      at org.hibernate.jdbc.BatchingBatcher.addToBatch(Batc hingBatcher.java:53)
                      at org.hibernate.persister.entity.AbstractEntityPersi ster.insert(AbstractEntityPersister.java:2434)
                      at org.hibernate.persister.entity.AbstractEntityPersi ster.insert(AbstractEntityPersister.java:2874)
                      at org.hibernate.action.EntityInsertAction.execute(En tityInsertAction.java:79)
                      at org.hibernate.engine.ActionQueue.execute(ActionQue ue.java:273)
                      at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:265)
                      at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:184)
                      at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:321)
                      at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:51)
                      at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:1216)
                      at org.hibernate.ejb.AbstractEntityManagerImpl.flush( AbstractEntityManagerImpl.java:960)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
                      at java.lang.reflect.Method.invoke(Method.java:618)
                      at org.springframework.orm.jpa.SharedEntityManagerCre ator$SharedEntityManagerInvocationHandler.invoke(S haredEntityManagerCreator.java:240)
                      at $Proxy41.flush(Unknown Source)
                      at com.malsolo.domain.Image_Roo_Jpa_ActiveRecord.ajc$ interMethod$com_malsolo_domain_Image_Roo_Jpa_Activ eRecord$com_malsolo_domain_Image$flush(Image_Roo_J pa_ActiveRecord.aj:60)
                      at com.malsolo.domain.Image.flush(Image.java:1)
                      at com.malsolo.domain.Image_Roo_Jpa_ActiveRecord.ajc$ interMethodDispatch1$com_malsolo_domain_Image_Roo_ Jpa_ActiveRecord$com_malsolo_domain_Image$flush(Im age_Roo_Jpa_ActiveRecord.aj)
                      at com.malsolo.domain.ImageIntegrationTest.testSaveAc tualTiffImage(ImageIntegrationTest.java:59)
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:79)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
                      at java.lang.reflect.Method.invoke(Method.java:618)
                      at org.junit.runners.model.FrameworkMethod$1.runRefle ctiveCall(FrameworkMethod.java:45)
                      at org.junit.internal.runners.model.ReflectiveCallabl e.run(ReflectiveCallable.java:15)
                      at org.junit.runners.model.FrameworkMethod.invokeExpl osively(FrameworkMethod.java:42)
                      at org.junit.internal.runners.statements.InvokeMethod .evaluate(InvokeMethod.java:20)
                      at org.springframework.test.context.junit4.statements .RunBeforeTestMethodCallbacks.evaluate(RunBeforeTe stMethodCallbacks.java:74)
                      at org.springframework.test.context.junit4.statements .RunAfterTestMethodCallbacks.evaluate(RunAfterTest MethodCallbacks.java:83)
                      at org.springframework.test.context.junit4.statements .SpringRepeat.evaluate(SpringRepeat.java:72)
                      at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.runChild(SpringJUnit4ClassRunner.jav a:231)
                      at org.junit.runners.BlockJUnit4ClassRunner.runChild( BlockJUnit4ClassRunner.java:47)
                      at org.junit.runners.ParentRunner$3.run(ParentRunner. java:231)
                      at org.junit.runners.ParentRunner$1.schedule(ParentRu nner.java:60)
                      at org.junit.runners.ParentRunner.runChildren(ParentR unner.java:229)
                      at org.junit.runners.ParentRunner.access$000(ParentRu nner.java:50)
                      at org.junit.runners.ParentRunner$2.evaluate(ParentRu nner.java:222)
                      at org.springframework.test.context.junit4.statements .RunBeforeTestClassCallbacks.evaluate(RunBeforeTes tClassCallbacks.java:61)
                      at org.springframework.test.context.junit4.statements .RunAfterTestClassCallbacks.evaluate(RunAfterTestC lassCallbacks.java:71)
                      at org.junit.runners.ParentRunner.run(ParentRunner.ja va:300)
                      at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.run(SpringJUnit4ClassRunner.java:174 )
                      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:50)
                      at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:467)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:683)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:390)
                      at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:197)
                      2012-02-22 17:12:30,382 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 17090, SQLState: null
                      2012-02-22 17:12:30,382 [main] ERROR org.hibernate.util.JDBCExceptionReporter - operación no permitida: streams type cannot be used in batching
                      2012-02-22 17:12:30,387 [main] DEBUG org.hibernate.ejb.AbstractEntityManagerImpl - mark transaction for rollback
                      2012-02-22 17:12:30,387 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Participating transaction failed - marking existing transaction as rollback-only
                      2012-02-22 17:12:30,387 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Setting JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@299c299c] rollback-only
                      2012-02-22 17:12:30,387 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Participating transaction failed - marking existing transaction as rollback-only
                      2012-02-22 17:12:30,387 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Setting JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@299c299c] rollback-only
                      2012-02-22 17:12:30,402 [main] DEBUG org.springframework.test.context.transaction.Trans actionalTestExecutionListener - No method-level @Rollback override: using default rollback [true] for test context [[TestContext@4bca4bca testClass = ImageIntegrationTest, testInstance = com.malsolo.domain.ImageIntegrationTest@6be06be, testMethod = testSaveActualTiffImage@ImageIntegrationTest, testException = org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.GenericJDBCException: could not insert: [com.malsolo.domain.Image]; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [com.malsolo.domain.Image], mergedContextConfiguration = [MergedContextConfiguration@5d8a5d8a testClass = ImageIntegrationTest, locations = '{classpath:/META-INF/spring/applicationContext*.xml}', classes = '{}', activeProfiles = '{}', contextLoader = 'org.springframework.test.context.support.Delegati ngSmartContextLoader']]]
                      2012-02-22 17:12:30,402 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Initiating transaction rollback
                      2012-02-22 17:12:30,402 [main] DEBUG org.springframework.orm.jpa.JpaTransactionManager - Rolling back JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@299c299c]
                      2012-02-22 17:12:30,402 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rollback
                      2012-02-22 17:12:30,407 [main] DEBUG org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
                      2012-02-22 17:12:30,407 [main] DEBUG org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection

                      Comment


                      • #12
                        But using...

                        Code:
                        jdbcTemplate.execute("insert into ...
                        Having configured:

                        Code:
                            <bean class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" id="nativeJdbcExtractor" />
                            
                            <bean class="org.springframework.jdbc.support.lob.OracleLobHandler" id="lobHandler">
                            	<property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" />
                            </bean>
                        Just works.

                        Comment


                        • #13
                          Hola Javier,

                          I am working on "something" totally Rooish of course... for dealing with this recurrent "issue" for now and forever.

                          So, stay tuned...

                          Hasta la vista
                          jD

                          Comment


                          • #14
                            Gracias

                            Comment


                            • #15
                              @jbbarquero,

                              As promised, here it is...
                              http://pragmatikroo.blogspot.com/201...ith-nosql.html.

                              It might be a little different of what you might expect. But definitely solve the issue for now and forever and for all legacy sql dbms with same issue. Besides is totally Rooish! in nature.

                              I hope it helps you.
                              B. Roogards
                              jD

                              Comment

                              Working...
                              X