Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Exceptions when using generics (was Upgrade from 1.1.0-M5 to 2.0.2)

Frank,
Correction, I see Entity MyClass extends MappedSuperclass MyGeneric where F is of type MyGenericType In this case MyField still must be an Entity, however a MyGenericType subclass of MyField could still be a MappedSuperclass as in an MS-->E hierarchy like CoordinateMS --> GalacticPosition in our JPA test model
UML:
http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#Mapped_Superclass_Test_Model
Code:
http://fisheye2.atlassian.com/browse/eclipselink/trunk/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/metamodel/CoordinateMS.java?r=HEAD

   - retesting
   /michael

Michael O'Brien wrote:
Frank,
Hi, I could find no relationship to the MyClass entity in the MyGeneric mappedSuperclass. If MyClass would actually be MyField - then the code should validate ok. Could you supply the code for the MyField class (F in this case should be a concrete entity subclass in your client code). Normally relationships out of MappedSuperclasses must be only to entities.

For example I get the following expected exception when i target a MappedSuperclass as the target of a OneToOne

Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - org.eclipse.persistence.exceptions.ValidationException Exception Description: [class org.eclipse.persistence.example.dataparallel.model.ScalarProcessingUnit] uses a non-entity [class org.eclipse.persistence.example.dataparallel.model.ProcessingUnit] as target entity in the relationship attribute [field westUnit]. at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210)

@MappedSuperclass
public abstract class Core {}

@MappedSuperclass
public abstract class ProcessingUnit<P extends Core> implements Serializable {
   @OneToOne
   private ProcessingUnit<P> westUnit;
}

@Entity(name="DparPU")
public class ScalarProcessingUnit extends ProcessingUnit implements Serializable {}

If I instead reference the entity subclass for the @OneToOne (virtually the same as a @ManyToOne) - I no longer get a validation exception.

   @OneToOne
   private ScalarProcessingUnit westUnit;

   thank you
   /michael


Frank von Daak wrote:
Hello again,

after searching the whole day for a solution, I try to get a little help on the list.

After upgrading from Eclipselink 1.1.0 to 2.0.2, I always get Exceptions, when starting up the application:

Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException Exception Description: [class de.myapp.domain.MyClass] uses a non-entity [class java.lang.String] as target entity in the relationship attribute [field myfield].

I am using Generics - mabye, this causes the problem!?

The classes look like this:
--------------------------------------------
@Entity
public class MyClass extends MyGeneric<MyGenericType>{
......
}  --------------------------------------------

@MappedSuperclass
@Cache(type=CacheType.NONE, alwaysRefresh=true)
public abstract class MyGeneric <F extends MyField > implements MyInterface {
     @ManyToOne
   private F myfield;  ....
}
--------------------------------------------

What is wrong with this code?
Who can give me a little help?

Thank you very much!
Frank

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





Back to the top