-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate's CascadeType causes compile errors
PostPosted: Tue Nov 28, 2006 12:34 pm 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
Hibernate version: Annotations 3.2

Hi,

I'm having compilation problems when trying to use Hibernate's CascadeType. I get these errors no matter which CascadeType I use as long as it is from org.hibernate.annotations.CascadeType.

Code:
import javax.persistence.ManyToMany;
import org.hibernate.annotations.CascadeType;

class Customer {
    private Order orders;

    @ManyToMany(cascade=CascadeType.LOCK)
    public Order getOrders() {
        return orders;
    }
}


I get the compilation error:
Type mismatch: cannot convert from CascadeType to CascadeType[]

if I change the cascade to:
Code:
@ManyToMany(cascade={CascadeType.LOCK})


I get the compilation error:
Type mismatch: cannot convert from CascadeType to CascadeType

Is this a bug or am I don't something wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 1:00 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Are you sure this is ok?

public Order getOrders() {
return orders;
}


It should be something like "Set<Order> getOrders()"

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:02 pm 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
actually, that was just some code that I typed for the post and it's not really like that in real-life. The important thing is the cascade. If I use the java persistence class (without the LOCK), then it works. It's really the Hibernate class which doesn't work


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:22 pm 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
well @ManyToOne accepts javax.persistence.CascadeType not org.hibernate.annotations.CascadeType.

remember that javax.* are specifications and are not dependent to any implementation.

you must use @org.hibernate.annotations.Cascade annotation for using org.hibernate.annotations.CascadeType.

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 5:01 am 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
Ok, I used the @Cascade annotation and that worked, but this annotation isn't mentioned in the Hibernate Annotations reference at all. If this is what I have to use, then it should be documented.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 6:14 pm 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
well I don't know which version of Hibernate Annotations you use, but it is documented in Hibernate Annotations 3.2 g.a.

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.