-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: AbstractMethodError/AssertionError when using generate attrb
PostPosted: Tue Apr 27, 2004 9:51 am 
Newbie

Joined: Mon Mar 29, 2004 7:10 pm
Posts: 16
Location: Minneapolis, MN/Topeka, KS
Hibernate Version=2.1
Database=IBM UDB 8.1
Java Level = 1.4.2
Env = Eclipse 3.0 (m8)
OS=Windows 2000

Problem -- when using generate attribute of either:
    sequence
    identity
    native
The following AbstractMethodError occurs -- see below --

(BTW -- the catch block for AbstractMethodError was added by me because I was catching Throwable in my invokation of Hibernate.



Code:
public static PreparedStatement prepareStatement(Connection conn, String sql) throws SQLException {
      Object[] args = new Object[] { sql, new Integer(RETURN_GENERATED_KEYS) } ;
      try {
         return (PreparedStatement) PREPARE_STATEMENT_METHOD.invoke(conn, args);
      }
      catch (InvocationTargetException ite) {
         if ( ite.getTargetException() instanceof SQLException ) {
            throw (SQLException) ite.getTargetException();
         }
         else if ( ite.getTargetException() instanceof RuntimeException ) {
            throw (RuntimeException) ite.getTargetException();
         }
         else {
            throw new AssertionFailure("InvocationTargetException", ite);
         }
      }
      catch (IllegalAccessException iae) {
         throw new AssertionFailure("IllegalAccessException", iae);
      }
My addition ---> catch (AbstractMethodError ame) {
        throw new AssertionFailure("AbstractMethodError", ame);
      }
   }

Code that generates the error is ---
Code:
p.addAddress(addr1);
        p.addAddress(addr2);
        // now save everything.
        //
        session = (Session) aFactory.openSession();
        tx = session.beginTransaction();
//        session.save(addr1);
//        session.save(addr2);
//       
        session.save(p);
        tx.commit();
        session.close();
      }



Stack trace follows:

Code:
21171 [main] INFO net.sf.hibernate.cache.QueryCache  - starting query cache at region: net.sf.hibernate.cache.QueryCache
Hibernate: insert into ECP.PARTY (PARTY_TYPE, PARTY_ID) values (?, default)
07:57:52,812 ERROR AssertionFailure:27 - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
java.lang.AbstractMethodError: COM.ibm.db2.jdbc.app.DB2Connection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
   at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:246)
   at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:521)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:423)
   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
   at org.srs.test.TestPersonWithAssignedIndices.main(TestPersonWithAssignedIndices.java:124)
22232 [main] ERROR net.sf.hibernate.AssertionFailure  - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
java.lang.AbstractMethodError: COM.ibm.db2.jdbc.app.DB2Connection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
   at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:246)
   at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:521)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:423)
   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
   at org.srs.test.TestPersonWithAssignedIndices.main(TestPersonWithAssignedIndices.java:124)
net.sf.hibernate.AssertionFailure: AbstractMethodError
   at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:56)
   at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:246)
   at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:521)
   at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:423)
   at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
   at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
   at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
   at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
   at org.srs.test.TestPersonWithAssignedIndices.main(TestPersonWithAssignedIndices.java:124)
Caused by: java.lang.AbstractMethodError: COM.ibm.db2.jdbc.app.DB2Connection.prepareStatement(Ljava/lang/String;I)Ljava/sql/PreparedStatement;
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at net.sf.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
   ... 10 more

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- $Id: Address.hbm.xml,v 1.5 2004/04/21 19:09:30 emm Exp $ -->
<hibernate-mapping>
    <class
       name="org.srs.domain.Address"
       table="ECP.ADDRESS" >
      <id
         name="addressID"
         type="long"
         unsaved-value="any"
         column="ADDR_ID">
         <generator class="identity" />
      </id>
      <set name="parties"
         lazy="true"
         table="ECP.ASSC_PTY_ADDR" >
         <key column="FK_ADDR_ID" />
          <many-to-many class="org.srs.domain.SRSParty" column="FK_PTY_ID" />
        </set>
       <property
          name="addrType"     
          column="ADDR_TYPE"     
          not-null="true"    />
       <property
          name="line1"       
          column="STREET1"       
          not-null="true"      />
       <property
          name="line2"       
          column="STREET2"       
          not-null="false"   />
       <property
          name="city"       
          column="CITY"           
          not-null="true"       />
       <property
          name="state"     
          column="STATE"        
          not-null="true"      />
       <property
          name="strNum"     
          column="STR_NUM"       
          not-null="true"     />
       <property
          name="zip1"       
          column="POSTAL_CODE1"    
          not-null="true"     />
       <property
          name="zip2"       
          column="POSTAL_CODE2"    
          not-null="false"    /> 
    </class>

</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- $Id: Party.hbm.xml,v 1.8 2004/04/21 19:09:30 emm Exp $ -->
<hibernate-mapping package="org.srs.domain" >
   <class name="org.srs.domain.Party" table="ECP.PARTY" >
     <id name="partyID"
        type="long"
          column="PARTY_ID"
        unsaved-value="any" >
        <generator
           class="identity"/>
     </id>
     <property
        name="partyType"
        type="integer"
        column="PARTY_TYPE"/>
      <set
         name="addresses"
         table="ECP.ASSC_PTY_ADDR" 
         lazy="true" >
        <key column="FK_PTY_ID" />
        <many-to-many
           class="org.srs.domain.Address" column="FK_ADDR_ID" />   
     </set>
   
   <joined-subclass name="org.srs.domain.Person"
      extends="org.srs.domain.Party"
      table="ECP.PERSON">
      <key column="ID" />
     <property
        name="dob"      
        type="date"   
        not-null="true"
        column="DOB"/>
     <property
        name="name"     
        type="string" 
        not-null="true"
        length="30"   
        column="NAME" />
     <property
        name="LName"    
        type="string" 
        not-null="true"
        length="30"   
        column="LNAME" />
     <property
        name="sex"      
        type="string" 
        not-null="true"
        length="1"   
        column="SEX" />
     <property
        name="SSN"      
        type="string" 
        not-null="true"
        length="10"   
        column="SSN" />
      </joined-subclass>
   </class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- $Id: Address.hbm.xml,v 1.5 2004/04/21 19:09:30 emm Exp $ -->
<hibernate-mapping>
    <class
       name="org.srs.domain.SRSAddress"
       table="ECP.ADDRESS" >
      <id
         name="addressID"
         type="long"
         unsaved-value="any"
         column="ADDR_ID">
         <generator class="identity" />
      </id>
      <set name="parties"
         lazy="true"
         table="ECP.ASSC_PTY_ADDR" >
         <key column="FK_ADDR_ID" />
          <many-to-many class="org.srs.domain.SRSParty" column="FK_PTY_ID" />
        </set>
       <property
          name="addrType"     
          column="ADDR_TYPE"     
          not-null="true"    />
       <property
          name="line1"       
          column="STREET1"       
          not-null="true"      />
       <property
          name="line2"       
          column="STREET2"       
          not-null="false"   />
       <property
          name="city"       
          column="CITY"           
          not-null="true"       />
       <property
          name="state"     
          column="STATE"        
          not-null="true"      />
       <property
          name="strNum"     
          column="STR_NUM"       
          not-null="true"     />
       <property
          name="zip1"       
          column="POSTAL_CODE1"    
          not-null="true"     />
       <property
          name="zip2"       
          column="POSTAL_CODE2"    
          not-null="false"    /> 
    </class>

</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<!-- $Id: SRSParty.hbm.xml,v 1.1 2004/04/26 19:11:21 emm Exp $ -->
<hibernate-mapping package="org.srs.domain" >
   <class name="SRSParty" table="ECP.PARTY" >
     <id name="partyID"
        type="long"
          column="PARTY_ID"
        unsaved-value="any" >
        <generator
           class="identity"/>
     </id>
     <property
        name="partyType"
        type="integer"
        column="PARTY_TYPE"/>
      <set
         name="addresses"
         table="ECP.ASSC_PTY_ADDR" 
         lazy="true" >
        <key column="FK_PTY_ID" />
        <many-to-many
           class="org.srs.domain.Address" column="FK_ADDR_ID" />   
     </set>
    </class>
   </hibernate-mapping>


    [/code]

    Thanks in advance for all assistance.

    _________________
    Michael McConnell


    Top
     Profile  
     
     Post subject: FYI --- RE DB2JAVA.BAT
    PostPosted: Tue Apr 27, 2004 10:43 am 
    Newbie

    Joined: Mon Mar 29, 2004 7:10 pm
    Posts: 16
    Location: Minneapolis, MN/Topeka, KS
    I was going to run db2java.bat to see if that would help.

    I looked for the db2java.bat file that appears with DB2 7.x .. apparently
    DB2 8.1 does not ship with this bat file as it runs Java 1.2 by default.

    -M

    _________________
    Michael McConnell


    Top
     Profile  
     
     Post subject: Follow up note
    PostPosted: Tue Apr 27, 2004 11:03 am 
    Newbie

    Joined: Mon Mar 29, 2004 7:10 pm
    Posts: 16
    Location: Minneapolis, MN/Topeka, KS
    This example runs fine if I use
    Code:
    generator="assigned"


    Obviously, I would like to use DB2 generated keys if I can.

    Thanks.

    Michael

    _________________
    Michael McConnell


    Top
     Profile  
     
     Post subject:
    PostPosted: Tue Apr 27, 2004 11:31 am 
    Hibernate Team
    Hibernate Team

    Joined: Tue Aug 26, 2003 12:50 pm
    Posts: 5130
    Location: Melbourne, Australia
    Disable hibernate.use_get_generated_keys, or get a JDBC3 compatible driver.


    Top
     Profile  
     
     Post subject: Use of hibernate.use_get_generated_keys
    PostPosted: Tue Apr 27, 2004 12:44 pm 
    Newbie

    Joined: Mon Mar 29, 2004 7:10 pm
    Posts: 16
    Location: Minneapolis, MN/Topeka, KS
    Apparently hibernate.use_get_generated_keys="false" doesnt work.

    Am I specifying the parameters wrong? I did a search of Hibernate.org for the string 'use_get_generated_keys' and turned up nothing.

    _________________
    Michael McConnell


    Top
     Profile  
     
     Post subject:
    PostPosted: Tue Apr 27, 2004 9:38 pm 
    Hibernate Team
    Hibernate Team

    Joined: Tue Aug 26, 2003 12:50 pm
    Posts: 5130
    Location: Melbourne, Australia
    ugh

    hibernate.jdbc.use_get_generated_keys

    and get rid of the quotes


    Top
     Profile  
     
     Post subject: Thanks --
    PostPosted: Wed Apr 28, 2004 2:19 pm 
    Newbie

    Joined: Mon Mar 29, 2004 7:10 pm
    Posts: 16
    Location: Minneapolis, MN/Topeka, KS
    Apparently I found the reference within hibernate.properties just about the same time you were posting.

    -M

    _________________
    Michael McConnell


    Top
     Profile  
     
    Display posts from previous:  Sort by  
    Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

    All times are UTC - 5 hours [ DST ]


    You cannot post new topics in this forum
    You cannot reply to topics in this forum
    You cannot edit your posts in this forum
    You cannot delete your posts in this forum

    Search for:
    © Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.