[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] @ElementCollection with @Embeddables and weaving
|
Hi,
I use the EclipseLink javaagent for weaving. My entity class looks like the following:
@Entity
public class SomeEntity {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "SomeMap")
private Set<Pair> someSet = new HashSet<Pair>();
public Long getId() {
return id;
}
public void put(String key, String value) {
someSet.add(new Pair(key, value));
}
}
In the logs, I noticed this line:
[EL Config]: 2010-03-12 14:49:38.828--ServerSession(5506056)--Class com.test.SomeEntity could not be weaved for change tracking as it is not supported by its mappings.
This is probably by the collection of embeddables. Now, it is a config information so I ignored it and wanted to proceed. The code I invoke is the following:
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();
tx.begin();
s = em.find(SomeEntity.class, s.getId());
tx.commit();
When the second commit is invoked, the following exception is thrown:
[EL Warning]: 2010-03-12 14:49:39.531--UnitOfWork(27742346)--java.lang.NullPointerException
Exception in thread "main" javax.persistence.RollbackException: java.lang.NullPointerException
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at com.test.Start.main(Start.java:26)
Caused by: java.lang.NullPointerException
at org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy.createObjectChangeSet(AttributeChangeTrackingPolicy.java:57)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:89)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.compareForChange(ObjectBuilder.java:1574)
at org.eclipse.persistence.mappings.AggregateCollectionMapping.compareForChange(AggregateCollectionMapping.java:495)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(DeferredChangeDetectionPolicy.java:159)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(DeferredChangeDetectionPolicy.java:136)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:89)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:624)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1495)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1131)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
... 2 more
I have exactly the same problem for Map collection when the value is an embeddable. This seems somehow interconnected to the weaving warning I got earlier. The problem goes away when weaving is not used, but it exists when I deploy to GlassFish v3. Is this a bug?
I attach the full source code to the mail. Please remember to enable weaving.
Regards,
Rafał
Attachment:
EmbeddableCollectionTest.zip
Description: EmbeddableCollectionTest.zip