Kundera Redis插件在查询时返回空列表

时间:2015-08-08 20:10:07

标签: kundera

我正在尝试解决一个问题,我无法使用Kundera查询返回redis后端的列表。我有问题返回单个实体,没有问题持久化实体。但是当我尝试做一个简单的选择以返回单个类型时,它总是返回一个空列表。

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
https://raw.github.com/impetus-opensource/Kundera/Kundera-2.0.4/kundera-core/src/test/resources/META-INF/persistence_2_0.xsd"
    version="2.0">


    <persistence-unit name="redis_pu">
        <provider>com.impetus.kundera.KunderaPersistence</provider>

        <class>com.factory.ng.api.domain.DomainEntity</class>
        <class>com.factory.ng.api.domain.Factory</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>

        <properties>
            <property name="kundera.show.query" value="true" />
            <property name="kundera.nodes" value="localhost" />
            <property name="kundera.port" value="6379" />
            <property name="kundera.keyspace" value="RedisK" />
            <property name="kundera.dialect" value="redis" />
            <property name="kundera.client" value="redis" />
            <property name="kundera.client.lookup.class" value="com.impetus.client.redis.RedisClientFactory" />
            <property name="kundera.transaction.resource.class" value="com.impetus.client.redis.RedisTransaction" />
            <property name="kundera.indexer.class" value="com.impetus.client.redis.RedisIndexer" />
        </properties>
    </persistence-unit>
    ...

这是我要检索的实体。

@Entity
@XmlRootElement
public class Factory extends DomainEntity implements IHasSlots {

    /**
     * Serialization Id
     */
    private static final long serialVersionUID = 7829467874878679280L;

    private String name;

    private List<Line> lines;

    public Factory() {
        this(null);
    }

    public Factory(String name) {
        this(name, new ArrayList<Line>());
    }

    public Factory(String name, Collection<Line> lines) {
        this(name, new ArrayList<Line>(lines));
    }
    ...

此单元测试始终以列表为空的断言错误结束。

@Test
public void testList() {
    EntityManagerFactory emFactory = Persistence.createEntityManagerFactory("redis_pu");
    EntityManager em = emFactory.createEntityManager();
    List<Factory> factories = em.createQuery("SELECT e FROM Factory e").getResultList();
    //Collection<Factory> factories = factoryDao.list();
    Assert.assertTrue(factories.size() > 0);
}

0 个答案:

没有答案