I get a net.sf.hibernate.MappingException: No persister for: java.lang.Integer
Hibernate version: 2.1.6
Mapping documents:
Code:
<hibernate-mapping package="mil.nows.app.nowsbase">
<class name="Request"
table="ORDERS">
<id name="trackingNumber"
column="TRACKING_NUMBER">
<generator class="sequence">
<param name="sequence">TRACKING_NUMBER_SEQ</param>
</generator>
</id>
<version name="version"
type="integer"
unsaved-value="null"
column="VERSION"/>
<bag name="orderFunding" order-by="FISCAL_YEAR ASC"
access="field"
inverse="true"
cascade="all-delete-orphan">
<key column="TRACKING_NUMBER"/>
<one-to-many class="RequestFunding"/>
</bag>
</class>
<class name="RequestFunding"
table="ORDERS_FUNDING">
<composite-id name="key"
access="field"
class="TrackingYearAppropriationKey">
<key-many-to-one name="trackingNumber"
class="Request"
column="TRACKING_NUMBER"/>
<key-property name="fiscalYear"
column="FISCAL_YEAR"/>
<key-property name="appropriationType"
column="APPROPRIATION_TYPE"/>
</composite-id>
<version name="version"
type="integer"
unsaved-value="null"
column="VERSION"/>
<many-to-one name="order"
class="Request"
column="TRACKING_NUMBER"
insert="false"
update="false"
not-null="true"/>
</class>
</hibernate-mapping>
Code for TrackingYearAppropriationKey class:Code:
package mil.nows.app.nowsbase;
import java.io.Serializable;
public class TrackingYearAppropriationKey implements Serializable {
private int trackingNumber;
private int fiscalYear;
private String appropriationType;
public TrackingYearAppropriationKey() {}
public TrackingYearAppropriationKey(int trackingNumber, int fiscalYear, String appropriationType) {
setTrackingNumber(trackingNumber);
setFiscalYear(fiscalYear);
setAppropriationType(appropriationType);
}
public int getTrackingNumber() {
return trackingNumber;
}
public void setTrackingNumber(int trackingNumber) {
this.trackingNumber = trackingNumber;
}
public int getFiscalYear() {
return fiscalYear;
}
public void setFiscalYear(int fiscalYear) {
this.fiscalYear = fiscalYear;
}
public String getAppropriationType() {
return appropriationType;
}
public void setAppropriationType(String appropriationType) {
this.appropriationType = appropriationType;
}
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TrackingYearAppropriationKey)) return false;
TrackingYearAppropriationKey other = (TrackingYearAppropriationKey) o;
return trackingNumber == other.trackingNumber &&
fiscalYear == other.fiscalYear &&
appropriationType == null ? other.appropriationType == null :
appropriationType.equals(other.appropriationType);
}
public int hashCode() {
int result = 17;
result = 37 * result + getTrackingNumber();
result = 37 * result + getFiscalYear();
result = 37 * result + (getAppropriationType() == null ? 0 : getAppropriationType().hashCode());
return result;
}
public String toString() {
return "TrackingYearAppropriationKey[" + trackingNumber + "," + fiscalYear + "," + appropriationType + "]";
}
}
Code between sessionFactory.openSession() and session.close():Code:
Integer id = (Integer) getSession().save(request);
Full stack trace of any exception that occurs:Code:
net.sf.hibernate.MappingException: No persister for: java.lang.Integer
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2759)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:399)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at neil.persistence.PersistenceUtil.commitTransaction(PersistenceUtil.java:187)
at neil.TestRequestDao.main(TestRequestDao.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Name and version of the database you are using:Oracle9i Enterprise Edition Release 9.2.0.3.0
The generated SQL (show_sql=true):Code:
Hibernate: insert into ORDERS (VERSION, TRACKING_NUMBER) values (?, ?)
Hibernate: insert into ORDERS_FUNDING (VERSION, TRACKING_NUMBER, FISCAL_YEAR, APPROPRIATION_TYPE) values (?, ?, ?, ?)
Debug level Hibernate log excerpt:Code:
12:32:15,953 INFO Environment: Hibernate 2.1.6
12:32:15,953 INFO Environment: hibernate.properties not found
12:32:15,968 INFO Environment: using CGLIB reflection optimizer
12:32:16,484 INFO Binder: Mapping class: mil.nows.app.nowsbase.Request -> ORDERS
12:32:17,171 INFO Binder: Mapping class: mil.nows.app.nowsbase.RequestFunding -> ORDERS_FUNDING
12:32:17,203 INFO Configuration: processing one-to-many association mappings
12:32:17,203 INFO Binder: Mapping collection: mil.nows.app.nowsbase.Request.orderFunding -> ORDERS_FUNDING
12:32:17,203 INFO Configuration: processing one-to-one association property references
12:32:17,203 INFO Configuration: processing foreign key constraints
12:32:17,234 INFO Dialect: Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
12:32:17,234 INFO SettingsFactory: Use outer join fetching: true
12:32:17,249 INFO DriverManagerConnectionProvider: Using Hibernate built-in connection pool (not for production use!)
12:32:17,249 INFO DriverManagerConnectionProvider: Hibernate connection pool size: 1
12:32:17,265 INFO DriverManagerConnectionProvider: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@now:1521:nowsdev
12:32:17,265 INFO DriverManagerConnectionProvider: connection properties: {user=ows, password=dev}
12:32:17,265 INFO TransactionFactoryFactory: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
12:32:17,265 INFO TransactionManagerLookupFactory: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
12:32:17,859 INFO SettingsFactory: Use scrollable result sets: true
12:32:17,859 INFO SettingsFactory: Use JDBC3 getGeneratedKeys(): false
12:32:17,859 INFO SettingsFactory: Optimize cache for minimal puts: false
12:32:17,859 INFO SettingsFactory: echoing all SQL to stdout
12:32:17,859 INFO SettingsFactory: Query language substitutions: {}
12:32:17,859 INFO SettingsFactory: cache provider: net.sf.ehcache.hibernate.Provider
12:32:17,874 INFO Configuration: instantiating and configuring caches
12:32:17,890 INFO SessionFactoryImpl: building session factory
12:32:18,624 INFO SessionFactoryObjectFactory: Not binding factory to JNDI, no JNDI name configured
Hibernate: insert into ORDERS (VERSION, TRACKING_NUMBER) values (?, ?)
12:32:19,093 DEBUG IntegerType: binding '0' to parameter: 1
12:32:19,109 DEBUG IntegerType: binding '99999999' to parameter: 2
Hibernate: insert into ORDERS_FUNDING (VERSION, TRACKING_NUMBER, FISCAL_YEAR, APPROPRIATION_TYPE) values (?, ?, ?, ?)
12:32:19,140 DEBUG IntegerType: binding '0' to parameter: 1
12:32:19,156 ERROR SessionImpl: Could not synchronize database state with session
net.sf.hibernate.MappingException: No persister for: java.lang.Integer
at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2759)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
at net.sf.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:154)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:399)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at neil.persistence.PersistenceUtil.commitTransaction(PersistenceUtil.java:187)
at neil.TestRequestDao.main(TestRequestDao.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)