Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2448

java.lang.Integer cannot be cast to java.lang.Long

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: kernel
    • Labels:
      None
    • Environment:
      SLES 11
      JRE 6 U15
      Glassfish 2.1.1

      Description

      We have following error without any changes on application or other related liberalizes.

      <openjpa-1.2.2-r422266:898935 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: java.lang.Integer cannot be cast to java.lang.Long
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:894)
      at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:793)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:986)
      at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:278)
      at org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2413)
      at org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:272)
      at org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
      at org.apache.openjpa.kernel.QueryImpl.singleResult(QueryImpl.java:1294)
      at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1221)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805)
      at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775)
      at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:533)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:252)
      at org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:317)

      this is my persistence.xml file:
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
      version="1.0">

      <persistence-unit name="pu-core90" transaction-type="JTA">
      <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
      <jta-data-source>jdbc/coreDS</jta-data-source>
      <mapping-file>META-INF/orm.xml</mapping-file>
      ...
      <class>com.core90.da.UserSession</class>
      ...
      <properties>
      <property name="openjpa.jdbc.DBDictionary"
      value="oracle(batchLimit=0,maxEmbeddedBlobSize=-1,maxEmbeddedClobSize=-1)" />

      <property name="openjpa.jdbc.SynchronizeMappings"
      value="buildSchema(foreignKeys=true,schemaAction='none')"/>
      <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"/>
      <property name="openjpa.RestoreState" value="all"/>

      <property name="openjpa.TransactionMode" value="managed" />
      <property name="openjpa.ManagedRuntime" value="jndi(TransactionManagerName=java:appserver/TransactionManager)" />
      <property name="openjpa.DataCache" value="false"/>
      <property name="openjpa.RemoteCommitProvider" value="sjvm" />
      <property name="openjpa.IgnoreChanges" value="true" />

      </properties>

      </persistence-unit>

      </persistence>

      this is my entity class:
      @Entity
      @Table(name="SESSION", uniqueConstraints={@javax.persistence.UniqueConstraint(columnNames=

      {"SESUID"})})
      @DataCache(enabled=false)
      public class UserSession {

      @Id
      @Column(name="ID")
      private Long id;

      @Column(name="CRTTIM")
      @Temporal(TemporalType.TIMESTAMP)
      private Date loginDate;

      @Column(name="TIMOUT")
      private Long timeout;

      @Column(name="SESUID", unique=true)
      private String sessionId;

      @Column(name="LSTACCSTIM")
      @Temporal(TemporalType.TIMESTAMP)
      private Date lastAccessTime;

      @Column(name="CLNTIP")
      private String clientIP;
      ...
      }

      we have old version of this entity that located in another class and there is a bit difference in timeout variable(data type is Integer). is this difference lead to this issue? please consider that there isn't any any scenario in application that calls UserSessionOld class.

      @Entity
      @Table(name="SESSION", uniqueConstraints={@javax.persistence.UniqueConstraint(columnNames={"SESUID"}

      )})
      @DataCache(enabled=false)
      public class UserSessionOld {

      @Id
      @Column(name="ID")
      private Long id;

      @Column(name="CRTTIM")
      @Temporal(TemporalType.TIMESTAMP)
      private Date loginDate;

      @Column(name="TIMOUT")
      private Integer timeout;

      @Column(name="SESUID", unique=true)
      private String sessionId;

      @Column(name="LSTACCSTIM")
      @Temporal(TemporalType.TIMESTAMP)
      private Date lastAccessTime;

      @Column(name="CLNTIP")
      private String clientIP;
      ...
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              hmmahboobi@gmail.com hm
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: