[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] @ElementCollection with @Embeddables
|
Hi Rafal,
What do the insert statements look like when the objects are inserted.
(persistence unit property eclipselink.logging.level=FINEST)?
Are you using EclipseLink to gennerate DDL? What do the table creation
statements look like?
-Tom
Swierzynski, Rafal wrote:
Hi,
I have such collection mapping:
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "SomeMap")
private Set<Pair> someSet = new HashSet<Pair>();
with Pair being defined as:
@Embeddable
public class Pair {
private String key;
private String value;
public Pair(String key, String value) {
this.key = key;
this.value = value;
}
protected Pair() {
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
}
The code to persist is as follows:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("TestJPA");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
SomeEntity s = new SomeEntity();
s.put("en", "table");
s.put("de", "Tish");
s.put("pl", "stół");
em.persist(s);
tx.commit();
em.clear();
s = em.find(SomeEntity.class, s.getId());
The entity is persisted in the database in the first transaction. However, when the entity is read again, I get:
Exception in thread "main" Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = bigint
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 53
Error Code: 0
Call: SELECT VALUE, KEY FROM SomeMap WHERE (SomeEntity_ID = ?)
bind => [1]
Query: ReadAllQuery(name="someSet" referenceClass=Pair sql="SELECT VALUE, KEY FROM SomeMap WHERE (SomeEntity_ID = ?)")
When I looked into the generated table for the collection, I noticed that SomeEntity_ID is of type "character varying".
What am I doing wrong here?
A project is attached to this email with the whole source code.
Regards,
Rafał
------------------------------------------------------------------------
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users