Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 在@ebeded对象中延迟加载@Forumla字段_Hibernate_Jpa_Hibernate Mapping - Fatal编程技术网

Hibernate 在@ebeded对象中延迟加载@Forumla字段

Hibernate 在@ebeded对象中延迟加载@Forumla字段,hibernate,jpa,hibernate-mapping,Hibernate,Jpa,Hibernate Mapping,我有一个带有@Formula字段的@Embedded对象,我在其中添加了@Basic(fetch=FetchType.LAZY),我正在使用字节码增强。在实际的@实体中使用@公式时,它会注意延迟加载。当@Formula是@Embedded的一部分时,它似乎不起作用。有没有办法做到这一点?我错过什么了吗 @Entity public class Foo { private Bar bar; @Embedded public Bar getBar () { return

我有一个带有@Formula字段的@Embedded对象,我在其中添加了@Basic(fetch=FetchType.LAZY),我正在使用字节码增强。在实际的@实体中使用@公式时,它会注意延迟加载。当@Formula是@Embedded的一部分时,它似乎不起作用。有没有办法做到这一点?我错过什么了吗

@Entity
public class Foo {

  private Bar bar;


  @Embedded
  public Bar getBar () {

    return ;
  }

  public void setBar (Bar bar) {

    this.bar = bar;
  }
}

@Embeddable
public class Bar {

  private int bazzCount;

  @Basic(fetch = FetchType.LAZY)
  @Formula("(select count(*) from bazzes)")
  public int getBazzCount () {

    return bazzCount;
  }

  public void setBazzCount (int bazzCount) {

    this.bazzCount = bazzCount;
  }
}