0

I am having a transaction using spring data , and I am trying to do an save operation (insert operation) . [SQL0913] Row or object table in Schema type *FILE in use.

Following is the entity

@Entity
@IdClass(OsytxlId.class)
@Table(name="OSYTXL")
@NamedQuery(name="Osytxl.findAll", query="SELECT o FROM Osytxl o")
public class Osytxl implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="TLCONO")
    private BigDecimal tlcono;

    @Id
    @Column(name="TLDIVI")
    private String tldivi;

    @Id
    @Column(name="TLLINO")
    private BigDecimal tllino;

    @Column(name="TLLMTS")
    private BigDecimal tllmts;

    @Id
    @Column(name="TLLNCD")
    private String tllncd;

    @Column(name="TLTX60")
    private String tltx60;

    @Id
    @Column(name="TLTXID")
    private BigDecimal tltxid;

    @Id
    @Column(name="TLTXVR")
    private String tltxvr;

    //getter and setters

}

I am using springdata-jpa And I am calling the following code portion from the service implementation class Before the following insertion , I need to delete the contents before insert .

            Osytxl osytxl = null;
            Collection<Osytxl> osytxlList = new ArrayList<Osytxl>();
            for (int lineNo = 0; lineNo < lines.length; lineNo++) {
                osytxl = new Osytxl();
                osytxl.setTlcono(osytxh.getThcono());
                osytxl.setTldivi(osytxh.getThdivi());
                osytxl.setTltxid(osytxh.getThtxid());
                osytxl.setTltxvr(osytxh.getThtxvr());
                osytxl.setTllncd(osytxh.getThlncd());
                osytxl.setTllmts(new BigDecimal("1437651510403"));
                osytxl.setTllino(new BigDecimal(lineNo+1));
                osytxl.setTltx60(lines[lineNo]);
                osytxlList.add(osytxl);
            }
            if(osytxlList.size()>0)
                osytxlRepository.save(osytxlList);

And I am using JPA repository But I am getting the following exception

org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.GenericJDBCException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:415)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:418)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy107.saveAndFlush(Unknown Source)


........................................................



Caused by: java.sql.SQLException: [SQL0913] Row or object OSYTXL in schema type *FILE in use.
at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:877)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:706)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:676)
at com.ibm.as400.access.AS400JDBCStatement.commonExecute(AS400JDBCStatement.java:1021)
at com.ibm.as400.access.AS400JDBCPreparedStatement.executeUpdate(AS400JDBCPreparedStatement.java:1825)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
... 127 more

I am using iseries (DB2) .Am I missing something or there anything I need to do extra in persistence.xml . Can anyone help .

  • 1
    The important part is *Caused by: java.sql.SQLException: [SQL0913] Row or object OSYTXL in schema type *FILE in use.* Maybe https://www-304.ibm.com/support/docview.wss?uid=swg21163496 helps with this error. – Olaf Dietsche Jul 26 '15 at 13:17
  • have moved to separate method like below @Transactional(propagation=Propagation.REQUIRES_NEW,rollbackFor=RuntimeException.class) private void insertIntoOsytxl(String[] lines,Osytxh osytxh) and copy pasted code snippet . but still same error –  Jul 26 '15 at 13:38
  • Have you also released all resources used earlier, i.e. closing existing connections or restarting the database? – Olaf Dietsche Jul 26 '15 at 14:04

1 Answers1

0

I've found on Experts Exchange that this could be due to queries outside of your application, locking the required records.

Adding FOR READ ONLY to your query like this:

SELECT * FROM FILE.TABLE
FOR READ ONLY
bluish
  • 26,356
  • 27
  • 122
  • 180
Ian
  • 11
  • 3