persistence@glassfish.java.net

AW: Problem with _at_AssociationOverride on Embedded ManyToOne Relation

From: Christian Kerwer <Christian.Kerwer_at_t-online.de>
Date: Wed, 6 Feb 2008 17:44:30 +0100

Thank you very much.

 

To be Toplink independent we do carry all the fields of the embedded type
into the entity and define the name there. In the getter we serve the
embedded type with the setted fields.

 

 

Christian Kerwer

 

  _____

Von: Gordon Yorke [mailto:gordon.yorke_at_oracle.com]
Gesendet: Mittwoch, 6. Februar 2008 15:28
An: persistence_at_glassfish.dev.java.net
Betreff: RE: Problem with @AssociationOverride on Embedded ManyToOne
Relation

 

First this is a bug so please file a issue in the bug tracker.

Second, you will need to remove the @AssociationOverride from your code and
use a session customer to update the join columns in native TopLink.

 

Persistence.xml entry:
<property name="toplink.session.customizer"
value="mypackage.EmbeddableCustomizer"/>

Customizer Class :

package mypackage;

 

import oracle.toplink.essentials.descriptors.ClassDescriptor;

import oracle.toplink.essentials.mappings.AggregateObjectMapping;

import oracle.toplink.essentials.sessions.Session;

import
oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer;

 

import ....ProcessActivityResult.class


public class EmbeddableCustomizer implements SessionCustomizer {

 

 public void customize(Session session) throws Exception {
  //get internal representation of Class to Database mappings
  ClassDescriptor descriptor =
(ClassDescriptor)session.getDescriptor(ProcessActivityResult.class);
          
 
((AggregateObjectMapping)descriptor.getMappingForAttributeName("valueActual"
)).addFieldNameTranslation("ACTUAL_SELECTIONLISTITEMID","SELECTIONLISTITEMID
");
 }
}
 

--Gordon

 

 -----Original Message-----
From: Christian Kerwer [mailto:Christian.Kerwer_at_t-online.de]
Sent: Wednesday, February 06, 2008 9:01 AM
To: persistence_at_glassfish.dev.java.net
Subject: Problem with @AssociationOverride on Embedded ManyToOne Relation

Hi everyone,

 

I'm trying to use an @AssociationOverride on a manyToOne relation of an
Emedded Type to rename the Column in the actual Entity:

 

@Entity

Public class ProcessActivityResult

{

   .

   @Embedded

   @AssociationOverride(name="selectionListItem",
joinColumns=_at_JoinColumn(name="ACTUAL_SELECTIONLISTITEMID"))

   private DynamicAttributeVal valueActual;

}

 

@Embeddable

public class DynamicAttributeVal

{

   .

   @ManyToOne

   @JoinColumn( name="SELECTIONLISTITEMID" )

   private SelectionListItem selectionListItem;

}

 

This leads to the following exception:

javax.persistence.PersistenceException: Exception [TOPLINK-28018] (Oracle
TopLink Essentials - 2.0.1 (Build b03-fcs (10/03/2007))):
oracle.toplink.essentials.exceptions.EntityManagerSetupException

Exception Description: predeploy for PersistenceUnit [toplink] failed.

Internal Exception: java.lang.NullPointerException

       at
oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy
(EntityManagerSetupImpl.java:643)

       at
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContai
nerEntityManagerFactory(EntityManagerFactoryProvider.java:244)

       at
com.sun.enterprise.server.PersistenceUnitLoaderImpl.load(PersistenceUnitLoad
erImpl.java:149)

       at
com.sun.enterprise.server.PersistenceUnitLoaderImpl.load(PersistenceUnitLoad
erImpl.java:84)

       at
com.sun.enterprise.server.AbstractLoader.loadPersistenceUnits(AbstractLoader
.java:898)

       at
com.sun.enterprise.server.ApplicationLoader.doLoad(ApplicationLoader.java:18
4)

       at
com.sun.enterprise.server.TomcatApplicationLoader.doLoad(TomcatApplicationLo
ader.java:126)

       at
com.sun.enterprise.server.AbstractLoader.load(AbstractLoader.java:244)

       at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:336)

       at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:230)

       at
com.sun.enterprise.server.ApplicationManager.applicationDeployed(Application
Manager.java:203)

       at
com.sun.enterprise.server.ApplicationManager.applicationEnabled(ApplicationM
anager.java:763)

       at
com.sun.enterprise.admin.event.AdminEventMulticaster.invokeApplicationDeploy
EventListener(AdminEventMulticaster.java:934)

       at
com.sun.enterprise.admin.event.AdminEventMulticaster.handleApplicationDeploy
Event(AdminEventMulticaster.java:912)

       at
com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEvent
Multicaster.java:461)

       at
com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEve
ntMulticaster.java:176)

       at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.sendEnableConfigChan
geEventExplicitly(ApplicationsConfigMBean.java:1834)

       at
com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.enable(ApplicationsC
onfigMBean.java:1902)

 

 

The second try using the AssociationOverride on the Entity like this:

 

@Entity

@AssociationOverride(name=" valueActual.selectionListItem",
joinColumns=_at_JoinColumn(name="ACTUAL_SELECTIONLISTITEMID"))

Public class ProcessActivityResult

{

   .

   @Embedded

   private DynamicAttributeVal valueActual;

}

 

Doesn't effect the renaming. In this case toplink looks up for a column
named ,SELECTIONLISTITEMID' instead of ,ACTUAL_SELECTIONLISTITEMID'.

 

Can anybody help, this is very urgent!

 

 

Christian Kerwer