尽管启用了字节码增强,但仍加载属性

时间:2020-05-11 12:29:41

标签: spring hibernate spring-boot jpa byte-code-enhancement

我有2个类,并且启用了字节码增强功能只是为了测试其功能。我的pom.xml如下:

    <plugin>
        <groupId>org.hibernate.orm.tooling</groupId>
        <artifactId>hibernate-enhance-maven-plugin</artifactId>
        <version>5.2.13.Final</version>
        <configuration>
            <failOnError>true</failOnError>
            <enableLazyInitialization>true</enableLazyInitialization>
            <enableDirtyTracking>false</enableDirtyTracking>
            <enableAssociationManagement>false</enableAssociationManagement>
        </configuration>
        <goals>
            <goal>enhance</goal>
        </goals>
    </plugin>
The Post Class
@Entity
@Table(name = "post")
@Getter @Setter
public class Post {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Lob
@Basic(fetch = FetchType.LAZY)
@LazyGroup("Test")
private String name;

private Boolean isDeleted = false;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true, mappedBy = "post")
private List<PostComment> postComments = new ArrayList<>();

}
The PostComment Class
@Entity
@Table(name = "post_comment")
@Getter @Setter
public class PostComment implements Serializable {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String comment;
private Boolean isDeleted = false;

@ManyToOne(fetch = FetchType.LAZY)
@JsonIgnore
@JoinColumn(name = "post_id", referencedColumnName = "id")
private Post post;

}

现在,当我尝试检索帖子时,尽管使用@Basic进行了注释,但最终仍将检索“名称”属性

Post post = postRepository.findById(1L).get();
Hibernate: select post0_.id as id1_0_0_, post0_.is_deleted as is_delet2_0_0_, post0_.name as name3_0_0_ from post post0_ where post0_.id=?

为什么要提取名称属性?

0 个答案:

没有答案
相关问题