-1

How to use the default and parameterized constructor using Lombok, after using the Lombok annotations for Constructor?

I have added the Lombok dependency in pom.xml but when I create the default and parameterized constructor it gives the error, The constructor BadgeCard(null, null, int, null) is undefined

BadgeCard.java

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.ToString;

@NoArgsConstructor
@RequiredArgsConstructor
@AllArgsConstructor
@Getter
@ToString
@EqualsAndHashCode
@Entity
public class BadgeCard {

    @Id
    @GeneratedValue
    @Column(name = "BADGE_ID")
    private Long badgeId;
    private Long userId;
    private long badgeTimestamp;
    private Badge badge;    

public BadgeCard() {
        this(null, null, 0, null);
    }

    public BadgeCard(final Long userId, final Badge badge) {
        this(null, userId, System.currentTimeMillis(), badge);
    }

}
farhanlq
  • 59
  • 2
  • 14
  • 1
    Possible duplicate of [How does lombok work?](https://stackoverflow.com/questions/6107197/how-does-lombok-work) – Karthikeyan Sep 05 '19 at 07:02
  • No, it's not duplicate. Actually I want to ask when I use Constructor annotation of Lombok. and write the default and parameterized constructor, I am getting the below errors. **The constructor BadgeCard(null, null, int, null) is undefined** – farhanlq Sep 05 '19 at 07:10
  • 1
    You're having Lombok create a no-args constructor, yet you're writing one yourself, why? – Strelok Sep 05 '19 at 07:30
  • That's what I want to ask I used the annotation, does it requires to create the create the constructer too? – farhanlq Sep 05 '19 at 07:36
  • Can you post your dependencies as well? – g00glen00b Sep 06 '19 at 11:35
  • The code you present here has errors, but not the errors that you claim. Either that, or your annotation processing is not enabled at all. – Michael Piefel Sep 10 '19 at 10:24

1 Answers1

1

NoArgsConstructor and AllArgsConstructor annotations are just enough for that

Halid
  • 150
  • 1
  • 7