1

Hibernate OGM,版本 5 Alpha,Windows 上的 Redis 3.0,Java SE1.8

所有 Hibernate OGM Jar 文件都在 Classpath 中。如果我删除String Variable #name变量的和 Setter-Getter 方法,它工作正常。

OGM000068:无法配置属性 test.Autor#name

OGM000059:找不到字符串的 GridType

我有以下例外:

INFO: OGM000001: Hibernate OGM 5.0.0.Alpha1
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: HLS] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:877)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:805)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
    at org.hibernate.ogm.jpa.HibernateOgmPersistence.createEntityManagerFactory(HibernateOgmPersistence.java:59)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at test.Main.main(Main.java:11)
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.ogm.persister.impl.SingleTableOgmEntityPersister
    at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:123)
    at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:346)
    at org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderImpl.build(OgmSessionFactoryBuilderImpl.java:54)
    at org.hibernate.ogm.boot.impl.OgmSessionFactoryBuilderImpl.build(OgmSessionFactoryBuilderImpl.java:23)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
    ... 5 more
Caused by: org.hibernate.HibernateException: OGM000068: Could not configure property test.Autor#name
    at org.hibernate.ogm.persister.impl.OgmEntityPersister.<init>(OgmEntityPersister.java:306)
    at org.hibernate.ogm.persister.impl.SingleTableOgmEntityPersister.<init>(SingleTableOgmEntityPersister.java:34)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
    ... 10 more
Caused by: org.hibernate.HibernateException: OGM000059: Unable to find a GridType for string
    at org.hibernate.ogm.type.impl.TypeTranslatorImpl.getType(TypeTranslatorImpl.java:85)
    at org.hibernate.ogm.persister.impl.OgmEntityPersister.<init>(OgmEntityPersister.java:303)
    ... 16 more



import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class Autor {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private int id;

    private long wert;

    private String name;

    public Autor() {

    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public long getWert() {
        return wert;
    }

    public void setWert(long wert) {
        this.wert = wert;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

public class Main {

    public static void main(String[] args) {
        EntityManagerFactory emf = Persistence
                .createEntityManagerFactory("HLS");
        EntityManager em = emf.createEntityManager();

        Autor a = new Autor();
        Autor b = new Autor();
        Autor c = new Autor();

        em.getTransaction().begin();
        em.persist(a);
        em.persist(b);
        em.persist(c);
        em.getTransaction().commit();

        System.out.println("ende");
    }
}


<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 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">

    <persistence-unit name="HLS" transaction-type="RESOURCE_LOCAL">
        <description>
            Persistence unit ...
        </description>
        <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
        <properties>
            <property name="hibernate.ogm.datastore.provider" value="redis_experimental"/>
            <property name="hibernate.ogm.datastore.host" value="localhost:6379"/>
            <property name="hibernate.ogm.datastore.database" value="0"/>
            <property name="hibernate.ogm.datastore.redis.association_storage" value="IN_ENTITY"/>
            <property name="hibernate.ogm.datastore.document.map_storage" value="BY_KEY"/>
        </properties>
    </persistence-unit>
</persistence>
4

0 回答 0