[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Inheritance Question

Hi Tom,

thanks for the reply.
I don't need the self generated serialversion id. I faced the problem and figured out the 2 solutions.
I'm asking because I'm interested.

Would you recommend to enable internal weaving always?

-Alex


On Mon, Apr 9, 2012 at 2:52 PM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
Our internal weaving is generating a serialversionid. ÂI suspect there is some conflict. ÂIs there any reason you need to be the one that generates the serialversion id?

-Tom


On 08/04/2012 11:38 AM, Alexander Mischur wrote:
Hi all,

Iâm using eclipselink 2.3.2 and jpa 2.0.3 and jdk 7u3

I have the following 3 classes:

@Entity
@Table(name = "book")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "clazz", discriminatorType = DiscriminatorType.STRING)
public abstract class Book implements Serializable {

  /**
  Â*
  Â*/
  private static final long serialVersionUID = 6958823087646370497L;

  @Id
  @GeneratedValue(strategy = GenerationType.TABLE)
  @Column(name = "id")
  private Long id;

  @Column(name = "title")
  private String title;

  @Column(name = "ISBN")
  private String isbn;

  @Column(name = "author")
  private String author;
}

@Entity(name = "PaperBook")
@DiscriminatorValue(value = "PaperBook")
public class PaperBook extends Book {

  @Column(name = "pages")
  private Integer pages;
}

@Entity(name = "AudioBook")
@DiscriminatorValue(value = "AudioBook")
public class AudioBook extends Book {

  @Column(name = "medium")
  private String medium;

  @Column(name = "length_in_minutes")
  private Integer lengthInMinutes;
}
My persistence.xml looks like this:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
      Âxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      Âxsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

<persistence-unit name="libraryPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>de.mischur.library.entities.Book</class>
<class>de.mischur.library.entities.PaperBook</class>
<class>de.mischur.library.entities.AudioBook</class>
</persistence-unit>

</persistence>

When I generate a serialVersionUID for one of the 3 classes and then execute a
select via persistenceManager I get this exception:

java.lang.AbstractMethodError:
de.mischur.library.entities.PaperBook._persistence_shallow_clone()Ljava/lang/Object;
at
org.eclipse.persistence.descriptors.copying.PersistenceEntityCopyPolicy.buildClone(PersistenceEntityCopyPolicy.java:35)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildBackupClone(ObjectBuilder.java:480)
at
org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.buildBackupClone(DeferredChangeDetectionPolicy.java:218)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuilder.java:1699)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:664)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:601)
at
org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:560)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:717)
at
org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:769)
at
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:433)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1081)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:392)
at
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1128)
at
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498)
at
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:742)
at de.mischur.library.dao.impl.GenericDaoImpl.findAll(GenericDaoImpl.java:54)
at de.mischur.library.dao.BookDaoTest.testFindAll(BookDaoTest.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at
org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at
org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at
org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

When I remove the serialVersionUID or disable internal-weaving
[eclipselink.weaving.internal=false] then everything works fine.

Can someone please explain what is going on in the background of eclipselink?
And why is everything working when internal-weaving at runtime is disabled?

Thank you in advance
Regards
Alex


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users