Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316067

Summary: ValidationException about referencing the correct subclass
Product: z_Archived Reporter: Sherry Hill <sherry.hill>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: christopher.delahunt, michael.f.obrien, mitesh.meswani
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
test description, source, usage and output none

Description Sherry Hill CLA 2010-06-07 18:39:53 EDT
Build Identifier: 2.1.0.v20100503-r7134

An inheritance test suite passed on Glassfish v3.0.1 b21 with EclipseLink 2.0.1,
but failed on Glassfish 3.1 b03 with EclipseLink 2.1.

Test source, usage and output will be enclosed.
inheritance.html: overview of tests
README:  usage
v301_b21: test output to show test passed.
v31_b03:  test output to show test failed with following error
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018]
(Eclipse Persistence Services - 2.1.0.v20100503-r7134): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [manager] failed.
Internal Exception: Exception [EclipseLink-7154]
(Eclipse Persistence Services - 2.1.0.v20100503-r7134):
org.eclipse.persistence.exceptions.ValidationException
Exception Description:
The attribute [VClients] in entity class [class ejb30.inherit.entity.VIPClientAgent]
has a mappedBy value of [vAgent] which does not exist in its owning entity class [class ejb30.inherit.entity.VIPClient].  If the owning entity class is a @MappedSuperclass,
this is invalid, and your attribute should reference the correct subclass.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:997)

From enclosed source, Class Hierrachy and code section, the owning entity is VIPClient,
which has vAgent and is not a @MappedSuperclass.  VIPClient's 2 level up parent Client is a
superclass.   I am not sure what is the problem.  Thanks for the advice.

Class Hierarchy
--BaseClient (concrete, non-entity)
  -->Client ( concrete, mapped superclass)
     -->DummyClient (concrete, entity)
        -->VIPClient (concrete, entity)
        -->RegularClient (entity, concrete)
--BaseAgent (concrete, mapped superclass)
  -->VIPClientAgent (concrete, entity) 
     --(with @IdClass -->VIPClientAgentPK with 3 primary keys)
     -->VIPClientAgentExt (concrete, entity)

In VIPClientAgent.java
@Entity
@IdClass(ejb30.inherit.entity.VIPClientAgentPK.class)
public class VIPClientAgent extends BaseAgent
    implements java.io.Serializable{
    private Collection<VIPClient> vClients;
    // ...
    @OneToMany(mappedBy="vAgent")
    public Collection<VIPClient> getVClients() {
        return vClients;
    }
    public void setVClients(Collection<VIPClient> v) {
        this.vClients = v;
    }

VIPClient.java
@Entity
public class VIPClient extends DummyClient {

    private boolean hasSaveBox;
    private VIPClientAgent vAgent;
    // ....
    @ManyToOne
    @JoinColumns ({
        @JoinColumn(name="FK_VA1", referencedColumnName="PK1I"),
        @JoinColumn(name="FK_VA2", referencedColumnName="PK2S")
    })
    public VIPClientAgent getVAgent() {
        return vAgent;
    }

    public void setVAgent(VIPClientAgent v) {
        vAgent = v;
    }

Reproducible: Always

Steps to Reproduce:
See README in attachment
Comment 1 Sherry Hill CLA 2010-06-07 18:46:15 EDT
Created attachment 171349 [details]
test description, source, usage and output
Comment 2 Sherry Hill CLA 2010-06-07 19:25:36 EDT
This issue is also tracked in glassfish 3.1.
https://glassfish.dev.java.net/issues/show_bug.cgi?id=12166
Comment 3 Chris Delahunt CLA 2010-06-14 16:10:05 EDT
This is the result of the fix in EclipseLink 2.1 for Bug 234222 - "property name generation differs from Introspector.decapitalize", a specification violation.  When using the property access, the correct property name to use for getVAgent() is "VAgent".  Any reference using a property name where the second character is capitalized will need to be changed, or field level access used instead.
Comment 4 Sherry Hill CLA 2010-06-17 12:13:53 EDT
Thanks for the explanation.  
The tests passed with using suggested change, i.e.
@OneToMany(mappedBy="VAgent")
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:05:23 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink