小编Kar*_*end的帖子

Hibernate ManyToOne与FetchType.LAZY不提取懒惰

我正在使用Hibernate和spring.

我有这样的模型类.


@Entity
@Table(name = "forumtopic")
public final class Forumtopic extends AbstractUserTracking implements
    java.io.Serializable {

/**SNIP **/

    private Forumcategory forumcategory;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FkForumcategoryId", nullable = false)
    public Forumcategory getForumcategory() {
        return this.forumcategory;
    }

    public void setForumcategory(final Forumcategory forumcategory) {
        this.forumcategory = forumcategory;
    }
}

Run Code Online (Sandbox Code Playgroud)

它一般工作,但类不是懒惰加载,但在加载ForumEntry后急切.

Hibernate: 
    select
        forumtopic0_.PkId as PkId19_0_,
        forumtopic0_.CreateDate as CreateDate19_0_,
        forumtopic0_.FkCreateUserId as FkCreate3_19_0_,
        forumtopic0_.FkLastUserId as FkLastUs4_19_0_,
        forumtopic0_.LastChange as LastChange19_0_,
        forumtopic0_.FkForumcategoryId as FkForum10_19_0_,
        forumtopic0_.PublishCategory as PublishC6_19_0_,
        forumtopic0_.State as State19_0_,
        forumtopic0_.Text as Text19_0_,
        forumtopic0_.Topic as Topic19_0_, …

spring maven-2 hibernate lazy-loading many-to-one

10
推荐指数
1
解决办法
1万
查看次数

来自类定义的GUI

是否有可以通过查看类或方法签名来构建简单GUI的库?

例如:

class MyMath{
    public static double sqrt(double d){
         //impl
    }
}       
Run Code Online (Sandbox Code Playgroud)

GUI

因此,当单击按钮时,将调用该方法并显示结果.

你知道Java或其他语言中有类似的例子吗?

谢谢

java reflection user-interface

6
推荐指数
1
解决办法
737
查看次数

过滤器挂起无限列表

我有这个代码

isPrime x = x > 0 && filter divisible [1..x] == [1,x]
where divisible y = x `mod` y == 0

primes = filter isPrime [1..]
Run Code Online (Sandbox Code Playgroud)

它定义了无限的素数列表.

所有这些案例都按预期工作:

*Main> take 10 primes
[2,3,5,7,11,13,17,19,23,29]

*Main> take 10 $ filter odd primes
[3,5,7,11,13,17,19,23,29,31]
Run Code Online (Sandbox Code Playgroud)

然而

*Main> take 10 $ filter even primes
[2
Run Code Online (Sandbox Code Playgroud)

挂起并且不会继续.我不知道为什么......我重新启动了ghci并且问题仍然存在.我正在使用ghc 8.0.1.

我的包裹:

C:\projects\littlethings\prime>ghc-pkg list
C:/Program Files/Haskell Platform/8.0.1\lib\package.conf.d
    Cabal-1.24.0.0
    GLURaw-2.0.0.1
    GLUT-2.7.0.7
    HTTP-4000.3.3
    HUnit-1.3.1.1
    ObjectName-1.1.0.1
    OpenGL-3.0.0.2
    OpenGLRaw-3.1.0.0
    QuickCheck-2.8.2
    StateVar-1.1.0.4
    Win32-2.3.1.1
    array-0.5.1.1
    async-2.1.0
    attoparsec-0.13.0.2
    base-4.9.0.0
    binary-0.8.3.0
    bytestring-0.10.8.1
    case-insensitive-1.2.0.6
    containers-0.5.7.1
    deepseq-1.4.2.0
    directory-1.2.6.2 …
Run Code Online (Sandbox Code Playgroud)

haskell

2
推荐指数
1
解决办法
213
查看次数