简体   繁体   English

如何使用Hibernate OGM检索嵌入式对象

[英]How to retrieve embedded objects using Hibernate OGM

I have two classes, where one is an entity and the other one is an @Embeddable object: 我有两个类,其中一个是实体,另一个是@Embeddable对象:

@Entity
public class A {
    @Id
    ...
    protected Integer id;
    @Embedded
    protected B b;
    protected String c;
}


@Embeddable
public class B {
    protected String d;
}

When i persist these in MongoDB, it works perfectly fine. 当我将这些保留在MongoDB中时,它可以很好地工作。 But when I query a tuple of A, b is null. 但是当我查询A的元组时,b为空。

This is how I tried querying: 这是我尝试查询的方式:

A a = em.find(A.class, 1);
A a = (A) em.createQuery("SELECT a FROM A a").getSingleResult();
A a = (A) em.createNativeQuery(A.class, "{}").getSingleResult();

Can somebody tell me how to solve this problem? 有人可以告诉我如何解决这个问题吗?

This bug has been solved some time ago. 该错误已在前一段时间解决。 This should work with the latest Hibernate OGM version 这应该与最新的Hibernate OGM版本一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM