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:
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.