我可以延迟加载FK对象,但热切加载其某些列吗

时间:2019-07-03 20:06:29

标签: hibernate jpa

我在模型中有一个对大型对象的ManyToOne FK引用,我只想访问所引用对象中的单个布尔值。 我在可能的地方使用了延迟加载,因此这仅对子对象有一个提示,但是我希望在加载时仅从该对象中获取一个或两个属性,而不必加载整个对象

    public class Parent {
        @ManyToOne(fetch = FetchType.Lazy, optional = true)
        @JoinColumn("FK_parent_child")
        private Child child;
    }

    public class Child {
        private int id;
        private int age;
        private boolean sex;
        private String name;
        ....
        ....
    }

当我引用Parent.getChild()。getAge()时。我只想获取年龄,而不必将整个Child对象加载到内存中。

在Hibernate / jpa中有可能吗?

0 个答案:

没有答案