-->
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: Need to understand cascade="create"
PostPosted: Wed Mar 23, 2005 12:22 pm 
Newbie

Joined: Tue Aug 26, 2003 12:31 pm
Posts: 14
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 12:49 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
change "create" to "persist"

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 1:34 pm 
Newbie

Joined: Tue Aug 26, 2003 12:31 pm
Posts: 14
Thanks for the clarification. Request: Please update doco. :) Also, will the annotation change to CascadeType.Persist or will that stay the same (CascadeType.Create) and have the same meaning?

Regards,

Mark


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 2:56 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
the doco should be up-to-date, if not, please tell where it isn't.
Annotation will follow changes.

And yes "create" and "persist" are the same, just forget about "create" you won't see it anymore.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 10:52 am 
Newbie

Joined: Wed May 05, 2004 1:00 pm
Posts: 7
It's on page 44 of the reference doc for Hibernate 3.0.2. The first paragraph after the attributes explanation for many-to-one.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 10:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
submit documentation improvment on jira please

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 09, 2005 5:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I fixed them in CVS, let me know if I missed some.

_________________
Emmanuel


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.