openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ionel Manolache <manolac...@yahoo.com>
Subject OpenJPA 1.1.0 and Exception: The result set is closed
Date Thu, 17 Jul 2008 12:00:14 GMT
Hi,

I made a small master/detail test.

@Entity
public class Master implements Serializable {

    @Id 
    @Column(name = "MASTERID", nullable = false)
    private Long id;

    @Column(name = "DESCRIPTION")
    private String description;

    @OneToMany(mappedBy = "fkMasterId")
    private List<Detail> detailCollection;

....

}


@Entity
public class Detail implements Serializable {

    @Id
    @Column(name = "DETAILID", nullable = false)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "FK_MASTERID", referencedColumnName = "MASTERID")
    private Master fkMasterId;

    @Column(name = "DESCRIPTION", nullable = false)
    private String description;

...
}

Then i have inserted some rows in both table, 'Master' and 'Detail'.
The problem appear when i try to update a row in 'Master' table:

List<Master> masterList = null;
EntityManager em = getEntityManagerFactory().createEntityManager();
try {
  Query query = em.createQuery("SELECT m FROM Master m");
  masterList = query.getResultList();
} finally {
  em.close();
  em = null;
}

System.out.println("masterList.size(): " + masterList.size());

Master modified = masterList.get(0);
modified.setDescription("master updated");

em = getEntityManagerFactory().createEntityManager();
try {
  EntityTransaction tx = em.getTransaction();
  try {
    tx.begin();
    Master merged = em.merge(modified);
    tx.commit();
  } finally {
    if (tx.isActive()) {
      tx.rollback();
    }
        }
} finally {
  em.close();
  em = null;
}

The stack trace is:
-------
Exception in thread "main" <openjpa-1.1.0-r422266:657916 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
The result set is closed
        at org.apache.openjpa.jdbc.sql.SQLExceptions.narrow(SQLExceptions.java:146)
        at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4150)
        at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
        at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88)
        at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:526)
        at org.apache.openjpa.kernel.DelegatingStoreManager.load(DelegatingStoreManager.java:116)
        at org.apache.openjpa.kernel.ROPStoreManager.load(ROPStoreManager.java:78)
        at org.apache.openjpa.kernel.StateManagerImpl.loadFields(StateManagerImpl.java:2911)
        at org.apache.openjpa.kernel.StateManagerImpl.loadField(StateManagerImpl.java:2989)
        at org.apache.openjpa.kernel.StateManagerImpl.fetchObjectField(StateManagerImpl.java:2238)
        at org.apache.openjpa.kernel.AttachStrategy.attachField(AttachStrategy.java:212)
        at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:161)
        at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
        at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
        at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3206)
        at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1158)
        at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:769)
        at Main.testMasterUpdate(Main.java:109)
        at Main.main(Main.java:167)
Caused by: org.firebirdsql.jdbc.FBSQLException: The result set is closed
        at org.firebirdsql.jdbc.AbstractResultSet.checkCursorMove(AbstractResultSet.java:217)
        at org.firebirdsql.jdbc.AbstractResultSet.next(AbstractResultSet.java:249)
        at org.apache.openjpa.lib.jdbc.DelegatingResultSet.next(DelegatingResultSet.java:106)
        at org.apache.openjpa.jdbc.sql.ResultSetResult.nextInternal(ResultSetResult.java:222)
        at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.nextInternal(SelectImpl.java:2285)
        at org.apache.openjpa.jdbc.sql.AbstractResult.next(AbstractResult.java:169)
        at org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.load(StoreCollectionFieldStrategy.java:476)
        at org.apache.openjpa.jdbc.meta.FieldMapping.load(FieldMapping.java:802)
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:520)
        ... 14 more
Java Result: 1


-------

My environment: Swing app, openJPA 1.1.0, jdk1.6.0_06, Firebird 2.1, Windows 2000. 

<persistence-unit name="TestPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>entity.Detail</class>
    <class>entity.Master</class>
    <properties>
      <property name="openjpa.ConnectionUserName" value="sysdba"/>
      <property name="openjpa.ConnectionPassword" value="xxx"/>
      <property name="openjpa.ConnectionURL" value="jdbc:firebirdsql://localhost/d:/test.fdb"/>
      <property name="openjpa.ConnectionDriverName" value="org.firebirdsql.jdbc.FBDriver"/>
    </properties>
</persistence-unit>


With OpenJPA version 1.0.2 and TopLink works fine. 

What is wrong? 
how to resolve or avoid the problem?

Thanks.


      

Mime
View raw message