简体   繁体   中英

Lombok @Builder with Inheritance and JPA

I have this class:

@Entity
@Table(name = "PERSONNE")
@Inheritance(strategy = InheritanceType.JOINED)
@NoArgsConstructor
@AllArgsConstructor
@Data
@SuperBuilder
@ToString
@EqualsAndHashCode(of = { "personneId" })
public class Personne implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "PERSONNE_ID")
    protected Long personneId;

}

and this other one

@Entity
    @Table(name = "DISSIDENT")
    @PrimaryKeyJoinColumn(name = "PERSONNE_ID")
    @Data
    @SuperBuilder
    @NoArgsConstructor
    @AllArgsConstructor
    @ToString(callSuper = true)
    @EqualsAndHashCode(callSuper = true)
    public class Dissident extends Personne {
    
        private static final long serialVersionUID = 1L;
    
    }

but when I run a test I got this error:

java: constructor Dissident() is already defined in class com.bar.peris.model.Dissident

Try changing the order of @NoArgsConstructor @AllArgsConstructor. Class by default have a no arg constructor unless a constructor is defined.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM