JPA2.0使用Map (1) 单向一对多,令人湿望的EclipseLink

@Entity
public class E implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    int id;
    String name;
    @OneToMany(cascade={PERSIST,REMOVE})
    Map<String, F> f = new HashMap<String, F>();
}

@Entity
public class F implements Serializable {

    @GeneratedValue(strategy = GenerationType.AUTO)
    @Id
    int id;
    String name;
}

public class Main {

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

        E e = new E();
        e.name = "i am e!";

        F f1 = new F();
        f1.name = "i am f1!";       
        F f2 = new F();
        f2.name = "i am f2!";
        e.f.put("f1", f1);
        e.f.put("f2", f2);

        em.persist(e);
        
        em.getTransaction().commit();
        em.close();
        emf.close();
    }
}

Hibernate下,okay! Key存入中间表了...同样,OpenJPA亦okay !
但是,EclipseLink失败了...Key位置为null...

你可能感兴趣的:(java,Hibernate,F#)