views:

193

answers:

5

What does following annotation's ElementType means?

@Entity
@Table(table="application")
@ElementType(type=1L) 
class application extends Element
A: 

That's a literal of type long and value 1. What it means depends on the definition of the annotation, but most likely there are constants defined in the ElementType annotation class that you're supposed to use instead of long literals.

Michael Borgwardt
+1  A: 

Please check: ElementType. It's an enum and all fields are defined there. You shouldn't rely on numeric values in your code.

bibix
A: 

Assuming this code compiles, there is a lot wrong with it. ElementType is an enum in the JDK, not an annotation, so this has to be a custom annotation interface. It uses a common annotation-related class name for an annotation, creating confusion. It uses a long instead of an enum, or at least a declared constant to define a type which is most likely not to be understood as a numeric. And it declares a class name in all lower case.

Yishai
A: 

The first two annotations are clearly Java Persistence annotations. There is no JPA or Hibernate annotation ElementType so it is not possible to tell from this code snippet what it means.

The fully qualified name for ElementType would provide some more clues, but more than likely this is a custom annotation; the definition of which resides in your code base.

Brad C
A: 

Why is it that the highest scoring answer (from bibx) is the only one that is WRONG?

@ElementType cannot be refering to java.lang.annotation.ElementType because its value cannot be a long.

I've only just registeref for StackOverflow so don't have enough reputation to vote things up or down, but someone ought to performs a 1 complement on all these scores.

The poster should answer the question about supplying the imports if they really want to k ow the answer to their question.