Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [eclipselink-users] @ElementCollection with @Embeddables and weaving

Hi Tom,
I think the most important difference is that this time I don't clear() the entity manager. You also need to enable weaving to get this exception, but this is probably not relevant to why I can go past the find(). The other code called clear() and hence EL had to fully load the entity from the database, whereas this time it is in the persistence context (it is application managed and hence extended). This time it fails when it tries to calculate the changes at commit / flush time.
This issue with weaving is the original problem I wanted to post. The other one, with the collection mapping and key types incompatibility, just popped up as I was creating the simplest possible test case for this issue to post on this list so that it is easy for readers to reproduce and maybe give hints. I gathered I was doing something wrong there and so I wanted to ask what is wrong.

Von: eclipselink-users-bounces@xxxxxxxxxxx [eclipselink-users-bounces@xxxxxxxxxxx] im Auftrag von Tom Ware [tom.ware@xxxxxxxxxx]
Gesendet: Freitag, 12. März 2010 16:42
An: EclipseLink User Discussions
Betreff: Re: [eclipselink-users] @ElementCollection with @Embeddables and       weaving

Hi Rafal,

   You posted an issue with a similar object model earlier that indicates that
the "find" does not work.  How is this scenario different - how are you getting
past the find?


Swierzynski, Rafal wrote:
> 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(
>       at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(
>       at com.test.Start.main(
> Caused by: java.lang.NullPointerException
>       at org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy.createObjectChangeSet(
>       at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(
>       at org.eclipse.persistence.internal.descriptors.ObjectBuilder.compareForChange(
>       at org.eclipse.persistence.mappings.AggregateCollectionMapping.compareForChange(
>       at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSetThroughComparison(
>       at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.createObjectChangeSet(
>       at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(
>       at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(
>       at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(
>       at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(
>       at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(
>       at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(
>       at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(
>       ... 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ł
> ------------------------------------------------------------------------
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
eclipselink-users mailing list

Back to the top