|
when setting the parameter for a query containing embeddables in an element collection i get the following exception:
the query:
em = emf.createEntityManager();
TypedQuery<Person> q = em.createQuery("select p from Person p where :book member of p.embeddableBooks", Person.class);
q.setParameter("book", book1);
q.getResultList();
the mapping of the person:
@ElementCollection
@CollectionTable(name = "Q_PERSON_BOOKS")
private List<EmbeddableBook> embeddableBooks = new ArrayList<EmbeddableBook>();
the person also contains the same EmbeddableBook as a single attribute and an ElementCollection od simple Strings:
@ElementCollection
@CollectionTable(name = "Q_PERSON_NICKNAMES")
private List<String> nicknames = new ArrayList<String>();
@Embedded
@AttributeOverrides(
{ @AttributeOverride(name = "name", column = @Column(name = "BOOK_NAME")),
@AttributeOverride(name = "author", column = @Column(name = "BOOK_AUTHOR")) })
private EmbeddableBook book;
querying thes attributes works:
em = emf.createEntityManager();
TypedQuery<Person> q = em.createQuery("select p from Person p where p.book = :book", Person.class);
q.setParameter("book", book1);
q.getResultList();
q = em.createQuery("select p from Person p where :nick member of p.nicknames", Person.class);
q.setParameter("nick", "Nick 1");
q.getResultList();
it's the combination of ElementCollection and Embeddable that does not work. A testCase is attached,
|