Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Adding a mapped-superclass via orm.xml fails
icon5.gif  Adding a mapped-superclass via orm.xml fails [message #726507] Sun, 18 September 2011 11:52 Go to next message
laeubi is currently offline laeubi
Messages: 6
Registered: September 2011
Junior Member
I have an generated class file I'd like to persist (so I can't add an annotation to it) so I tried to use the ORM.xml aproach to tell eclipse link that ist should use the fields in this class also.

For simplicity I removed all code from the generated code (of course it normaly contains field, but gave the same error), it just looks like this;
package de.rki.ibis200907;

public class LabResultType {

}

and a derived (annotated) class:
@Table(name = "mvare_labresulttype_200907")
@Entity
public class PersistentLabResultType extends LabResultType {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    public void setID(long id) {
        this.id = id;
    }

    public long getID() {
        return id;
    }
}

The orm.xml looks like this
<entity-mappings xmlns="java.sun.com/xml/ns/persistence/orm" 
    xmlns:xsi="w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
    version="1.0">
    <mapped-superclass class="de.rki.ibis200907.LabResultType" access="FIELD">
        
    </mapped-superclass>
</entity-mappings>

persistence.xml
<persistence version="1.0"
    xmlns="java.sun.com/xml/ns/persistence" xmlns:xsi="w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="java.sun.com/xml/ns/persistence java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="ibis200907"
        transaction-type="RESOURCE_LOCAL">
        <class>de.laeubisoft.ibis.rki.ibis200907.PersistentLabResultType</class>
        <class>de.rki.ibis200907.LabResultType</class>
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.target-database" value="MySQL"/>
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test" />
            <property name="javax.persistence.jdbc.driver"
                value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password"
                value="" />
            <property name="eclipselink.weaving" value="false"/>
            <property name="eclipselink.application-location" value="/tmp/"/>
            <property name="eclipselink.ddl-generation" value="create-tables"/>
            <property name="eclipselink.create-ddl-jdbc-file-name" value="create.sql"/>
            <property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
        </properties>
    </persistence-unit>
</persistence>


Finally the problem is I get the following error on schmea generation:
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [ibis200907] failed.
Internal Exception: java.lang.NullPointerException
	at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
	... 46 more
Caused by: java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.getProject(MetadataDescriptor.java:1086)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.<init>(ClassAccessor.java:253)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.<init>(MappedSuperclassAccessor.java:233)
	at org.eclipse.persistence.internal.jpa.metadata.ORMetadata.reloadMappedSuperclass(ORMetadata.java:618)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addPotentialMappedSuperclass(ClassAccessor.java:526)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.discoverMappedSuperclassesAndInheritanceParents(EntityAccessor.java:275)
	at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(EntityAccessor.java:514)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage1(MetadataProject.java:1590)
	at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:517)
	at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:526)
	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1320)
	... 45 more


If I add an @MappedSuperclass and omit the orm.xml everything works fine.

Does anyone has an hint what I'm doing wrong?

(I had to remove all transport protocoll specifierer from the URLs of the Schema uris because of the: You cannot use links until you have posted more than 5 messages. error)
Re: Adding a mapped-superclass via orm.xml fails [message #726870 is a reply to message #726507] Mon, 19 September 2011 18:39 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Seems to be a bug in mixing the two. Please log the bug and vote for it.

To workaround the issue try defining both in XML or both in annotations.


James : Wiki : Book : Blog : Twitter
Re: Adding a mapped-superclass via orm.xml fails [message #726875 is a reply to message #726870] Mon, 19 September 2011 18:43 Go to previous messageGo to next message
laeubi is currently offline laeubi
Messages: 6
Registered: September 2011
Junior Member
Hi James,

so you think it should normaly work this way? Do you know if it is okay that I link this topic in the bug description or should i copy everything over?
(no subject) [message #726881 is a reply to message #726507] Mon, 19 September 2011 18:39 Go to previous messageGo to next message
James is currently offline James
Messages: 272
Registered: July 2009
Senior Member
Seems to be a bug in mixing the two. Please log the bug and vote for it.

To workaround the issue try defining both in XML or both in annotations.

--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
Re: (no subject) [message #730490 is a reply to message #726875] Wed, 28 September 2011 14:15 Go to previous message
Guy Pelletier is currently offline Guy Pelletier
Messages: 19
Registered: July 2009
Junior Member
This issue has been addressed with the fix for bug 349906.

If possible, please try/use a nightly build of 2.3.1

http://www.eclipse.org/eclipselink/downloads/nightly.php

Otherwise, the work around as James suggested is to include the entity in XML
as well (just declare it in XML)

e.g.

<entity class="PersistentLabResultType"/>
Re: (no subject) [message #730512 is a reply to message #726875] Wed, 28 September 2011 14:15 Go to previous message
Guy Pelletier is currently offline Guy Pelletier
Messages: 19
Registered: July 2009
Junior Member
This issue has been addressed with the fix for bug 349906.

If possible, please try/use a nightly build of 2.3.1

http://www.eclipse.org/eclipselink/downloads/nightly.php

Otherwise, the work around as James suggested is to include the entity in XML
as well (just declare it in XML)

e.g.

<entity class="PersistentLabResultType"/>
Previous Topic:How to use outer joins in named query to calculate aggregate values?
Next Topic:JPA Relationship + Multi-Tenancy
Goto Forum:
  


Current Time: Tue Sep 30 14:13:10 GMT 2014

Powered by FUDForum. Page generated in 0.02161 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software