Questions tagged [java-annotations]

211 questions
131
votes
5 answers

what is the use of annotations @Id and @GeneratedValue(strategy = GenerationType.IDENTITY)? Why the generationtype is identity?

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) Why we are using this annotations? i need to know if this autoincrement my table id values. (GenerationType.IDENTITY) is there any other types whats actually happening when we use this…
Lijo
  • 6,498
  • 5
  • 49
  • 60
66
votes
4 answers

Is a Python Decorator the same as Java annotation, or Java with Aspects?

Are Python Decorators the same or similar, or fundamentally different to Java annotations or something like Spring AOP, or Aspect J?
bn.
  • 7,739
  • 7
  • 39
  • 54
51
votes
2 answers

Difference between @EntityScan and @ComponentScan

I am trying to understand the difference here. I see that a class has been annotated with both of them with same package example : @Configuration @EntityScan("some.known.persistence") @ComponentScan({ "some.known.persistence"}) public class…
Raghuveer
  • 2,859
  • 7
  • 34
  • 66
49
votes
1 answer

Using Room's @ForeignKey as @Entity parameter in Kotlin

I came across a Room tutorial that makes use of the @PrimaryKey annotation on the class definition: @Entity(foreignKeys = @ForeignKey(entity = User.class, parentColumns = "id", childColumns…
Chisko
  • 3,092
  • 6
  • 27
  • 45
30
votes
2 answers

Visual Studio Code - Java - Lombok - The method is undefined for the type

I downloaded the following project and imported it into Visual Studio Code: https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example I have a problem on the following class, when invoking:…
davidesp
  • 3,743
  • 10
  • 39
  • 77
27
votes
2 answers

Android studio warning - InnerClass annotations are missing corresponding EnclosingMember annotations

I recently upgraded to Android Studio 3.1 and upon building my Kotlin with Java project I got the following warning. InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored. Message…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
27
votes
1 answer

How to suppress lombok warnings

I have an Entity @Builder class MyEntity { private Set children = new HashSet<>() } And i get a lombok warning. warning: @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve…
Bukharov Sergey
  • 9,767
  • 5
  • 39
  • 54
13
votes
1 answer

Annotation processing, RoundEnvironment.processingOver()

While reading the code of a custom annotation processor in Java, I noticed this piece of code in the processor's process method: @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { if…
Mohammed Aouf Zouag
  • 17,042
  • 4
  • 41
  • 67
12
votes
1 answer

What is the relation between Spring @Transactional and Spring @Lock annotation?

I found that the @Transactional is used to ensure transaction on repository method or on a service method. @Lock is used on repository method to ensure locking of entity to provide isolation. Some questions are raised in my mind: What are major…
kayesh parvez
  • 323
  • 1
  • 2
  • 9
12
votes
1 answer

Additional methods in java Builder class (lombok annotation)

SO, I have class that uses @Builder lombok annotation. This is how it looks and how I use it: import lombok.Builder; import lombok.Data; import com.fasterxml.jackson.annotation.JsonProperty; @Data @Builder public class MyModel { …
Bilberryfm
  • 507
  • 2
  • 11
  • 28
11
votes
2 answers

How to create a customisation annotation for splitting request param and collect return result?

I have a method params is a list which is lager than 50000 items; Limited to the business logic, the list must less than 30000, so that I have a method to split this array to 2d array before the logic public static final Collection>…
Ben Luk
  • 735
  • 2
  • 8
  • 15
10
votes
2 answers

Repeatable annotation target subset mismatch compiler error

I have the following annotation; @Repeatable(Infos.class) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.Type, ElementType.Constructor}) public @interface Info { String[] value() default {}; } and as you see, it is repeatable, and…
buræquete
  • 14,226
  • 4
  • 44
  • 89
10
votes
1 answer

Writing custom lint warning to check for custom annotation

I have written the following annotation: import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import…
Adam
  • 2,167
  • 5
  • 19
  • 33
10
votes
5 answers

Mocking the Qualified beans using mockito for a spring-boot application

consider my scenario public class SomeClass { @Autowired @Qualifier("converter1") private IConverter converter1; @Autowired @Qualifier("converter2") private IConverter converter2; public void doSomeAction(String mimeType) { …
amith
  • 399
  • 1
  • 2
  • 11
9
votes
2 answers

org.jetbrains.annotations.NotNull instead of javax.annotation.Nonnull when implement method in Intellij IDEA

After recent JetBrains Intellij IDEA updates I found out that when I'm trying to implement method annotated with javax.annotation.Nonnull - IDE implements it with org.jetbrains.annotations.NotNull instead. Example: If you have an interface: import…
Mikita 123
  • 93
  • 1
  • 4
1
2 3
14 15