This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Annotation Error in Java Compiler

Hello Everyone, The hibernate cascade annotation value "org.hibernate" is conflicting with the variable "org", it's taking "org" as variable name, not part of the package name. I am getting error:

.java:[14,16] cannot find symbol
[ERROR] symbol  : variable hibernate
[ERROR] location: class java.lang.Object
[ERROR] Foo.java:[14,50] an enum annotation value must be an enum constant

It seems to be a generic Java compiler bug. I am using the online compiler to compile the program from here https://www.interviewbit.com/online-java-compiler/ and Should be reproducible when you define an object variable that is the same as the first package element.

import javax.persistence.CascadeType;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cascade;

public class Foo {
    Object org;

    @OneToMany
    @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
    Object foo;

    @OneToMany(cascade=CascadeType.ALL)
    Object foo2;
}