Reputation: 61
When my project run on spring 2.5 and hibernate 3.2 it works fine.After updating spring version to 4.1.6 and hibernate version to 3.6.1 i got the following error:
org.hibernate.MappingException: Unknown entity: java.util.ArrayList
My DAO function is :
public void updateAll(Collection<EntityType> collection) {
try {
getHibernateTemplate().saveOrUpdateAll(collection);
} catch (Exception e) {
logger.error("updateAll :"+e);
}
}
Configuration is :
<bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" id="sessionFactory">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>com.cptu.egp.eps.model.table.TblCountryMaster</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="current_session_context_class">thread</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.cache.provider_class"> net.sf.ehcache.hibernate.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_class"> net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
<prop key="hibernate.max_fetch_depth">5</prop>
<prop key="hibernate.default_batch_fetch_size">16</prop>
<prop key="hibernate.jdbc.batch_size">25</prop>
<prop key="hibernate.jdbc.fetch_size">8</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory" />
<bean class="org.springframework.orm.hibernate3.HibernateTemplate" id="hibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
My Entity Mapping class:
@Entity
@Table(name = "tbl_TenderEstCost", schema = "dbo")
public class TblTenderEstCost implements java.io.Serializable {
private int estCostLotId;
private TblTenderMaster tblTenderMaster;
public TblTenderEstCost() {
}
public TblTenderEstCost(int estCostLotId, TblTenderMaster tblTenderMaster) {
this.estCostLotId = estCostLotId;
this.tblTenderMaster = tblTenderMaster;
}
@Id
@GeneratedValue(generator = "TblTenderEstCostSequence", strategy = GenerationType.IDENTITY)
@SequenceGenerator(name = "TblTenderEstCostSequence", sequenceName = "tblTenderEstCost_sequence", allocationSize = 25)
@Column(name = "estCostLotId", unique = true, nullable = false)
public int getEstCostLotId() {
return this.estCostLotId;
}
public void setEstCostLotId(int estCostLotId) {
this.estCostLotId = estCostLotId;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "tenderId", nullable = false)
public TblTenderMaster getTblTenderMaster() {
return tblTenderMaster;
}
public void setTblTenderMaster(TblTenderMaster tblTenderMaster) {
this.tblTenderMaster = tblTenderMaster;
}
}`
Upvotes: 0
Views: 666
Reputation: 717
According to the source code, there isn't saveOrUpdateAll() method in 4.1.6., and it's also deprecated in spring 3.
It looks like you pass the collection to saveOrUpdate(), and hibernate can't find the mapping setting.
Upvotes: 1