Skip to content

Pro Spring Boot 2.Chapter 5-Spring Data JPA demo #1

@califodream

Description

@califodream

WARNING 1

@DaTa annotation should not be used with @entity annotation. There is a warning came from IDEA ,Using @Data for JPA entities is not recommended. It can cause severe performance and memory consumption issues.

@Entity
@Data
public class ToDo {
...
}

BUG 1

These two annotations, @GeneratedValue, and @GenericGenerator, do not work here. Therefore, The @NoArgsContructor
annotation will not offer any convenience for a clean code. You must have a no-args-contructor to initiate an instance including field and field.

@NotNull
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
private String id;

CONCLUSION

还需要进一步了解几个关键的注解,有@NoArgsContructor, @RequiredArgsContructor, @GeneratorValue, @GenericGenerator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions