Hibernate version: 3.0 RC1
Name and version of the database you are using: DB2 8.2
I am getting an error when I try to map a collection like this and initialize Hibernate:
Code:
<bag
name="orderLineItems"
table="TestOrderLineItem"
lazy="true"
inverse="true"
cascade="create,merge,save-update"
order-by="description,lineItemPrice"
>
<key
column="Order_ID"
/>
<one-to-many
class="com.meagle.bo.OrderLineItem"
/>
</bag>
Here is the error message:
org.hibernate.MappingException: Unsupported cascade style: create
at org.hibernate.engine.Cascades.getCascadeStyle(Cascades.java:961)
at org.hibernate.mapping.Property.getCascadeStyle(Property.java:92)
at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:115)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:145)
at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:398)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:104)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:568)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:503)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1073)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:343)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:260)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:145)
The documentation states this:
Quote:
"Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent
and children together in the same transaction, and you want to save yourself some typing, consider using
cascade="create,merge,save-update"."
Here is what I see inside org.hibernate.engine.Cascades:
Code:
private static final Map STYLES = new HashMap();
static {
STYLES.put("all", STYLE_ALL);
STYLES.put("all-delete-orphan", STYLE_ALL_DELETE_ORPHAN);
STYLES.put("save-update", STYLE_SAVE_UPDATE);
STYLES.put("persist", STYLE_PERSIST);
STYLES.put("merge", STYLE_MERGE);
STYLES.put("lock", STYLE_LOCK);
STYLES.put("refresh", STYLE_REFRESH);
STYLES.put("replicate", STYLE_REPLICATE);
STYLES.put("evict", STYLE_EVICT);
STYLES.put("delete", STYLE_DELETE);
STYLES.put("delete-orphan", STYLE_DELETE_ORPHAN);
STYLES.put("none", STYLE_NONE);
}
Should we use persist instead of create? Is the doco just wrong?
Regards,
Mark