java - Hibernate findByexample 问题

标签 java hibernate hbm

我有两个表用户和地址表

它们在 HBM 中的关系是

<!-- bi-directional one-to-one association to Address -->
    <one-to-one
        name="user"
        class="address"
        outer-join="auto"
    />

因此,当我在 User Pojo 中设置 Address Pojo 并为 User Pojo 调用 findByExample 时。

它忽略地址 Pojo

最佳答案

reference manual说:

Version properties, identifiers and associations are ignored.

但它也说:

You can even use examples to place criteria upon associated objects.

List results = session.createCriteria(Cat.class)
    .add( Example.create(cat) )
    .createCriteria("mate")
        .add( Example.create( cat.getMate() ) )
    .list();

关于java - Hibernate findByexample 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9076127/

相关文章:

java - 如何使用 ffmpeg Android 合并两个视频

java - 如何使用 Java Swing 仅验证 JFormattedText 中的 float ?

java - 映射 Spring 形状

java - Hibernate 急切地加载惰性引用

java - Swing - 更改 LayoutManager : two components per line

java - 如何在Spring Boot + Hibernate中实现 "delete"方法

java - 线程中的异常 "main"org.hibernate.AnnotationException : @OneToOne or @ManyToOne

hibernate - Hibernate hbm 文件中的 @Audited 注释

java - 级联在 hibernate 模式下无法正常工作