Bug 441920 - Support of Embedded/Embeddable buggy when an attribute annotated with EmbeddedId is inherited
Summary: Support of Embedded/Embeddable buggy when an attribute annotated with Embedde...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-17 08:51 EDT by Rodrigue Lagoue Njinthe CLA
Modified: 2022-06-09 10:10 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rodrigue Lagoue Njinthe CLA 2014-08-17 08:51:10 EDT
I encounter the exception eclipslink-7309 (INVALID_EMBEDDABLE_ATTRIBUTE_FOR_ATTRIBUTE_OVERRIDE) when having the following situation.

--------------------------------------
@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class DomainObject<T> {

   public abstract T getId();
   public abstract T setId(T id);
}

@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class DomainObjectWithSimpleId<T> extends DomainObject<T> {
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   @Column(name = "id")
   T id;

   public T getId() {
      return id;
   }

   public void setId(T id) {
      this.id = id;
   }
}

@MappedSuperclass
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class DomainObjectWithEmbeddedId<T> extends DomainObject<T> {
   @EmbeddedId
   T id;

   public T getId() {
      return id;
   }

   public void setId(T id) {
      this.id = id;
   }
}

@Embeddable
public class PhoneNumber {
   private String countryCode;
   private String number;
}

@Entity
@Table(name = "shop")
public class Shop extends DomainObjectWithSimpleId<Long> {
   private String name;

   @Embeddable
   @AttributeOverrides({
      @AttributeOverride(name = "countryCode", column = @Column(name = "countrycode")),
      @AttributeOverride(name = "number", column = @Column(name = "number")) })
   private PhoneNumber phoneNumber;
}

@Embeddable
public class SaleEntryItemPurchasePrimaryKey implements Serializable {
   private long saleEntryId;
   private long itemPurchaseId;
}

@Entity
@Table(name = "saleentry_itempurchase")
public class SaleEntryItemPurchase extends DomainObjectWithEmbeddedId<SaleEntryItemPurchasePrimaryKey> {
   private String quantity;
   
}

-----------------------

- All these classes are declared in the persistence.xml file
- As you can remark, the "Shop" doesn't have the hierachy with the EmbeddedId support.

So but when I start my application, the exception with the following message is thrown:

-----
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@6411c21b
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [warehouse] failed.
Internal Exception: Exception [EclipseLink-7309] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The attribute named [countryCode] from the embeddable class [class cm.bao.common.domain.PhoneNumber] is not a valid mapping to use with an attribute override for the attribute [phoneNumber] on class [class cm.bao.warehouse.core.domain.Shop].
	at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
	at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
-----

The problem no more occurs when I declare the class SaleEntryItemPurchase like this: 

-------
@Entity
@Table(name = "saleentry_itempurchase")
public class SaleEntryItemPurchase extends DomainObjectWithEmbeddedId<SaleEntryItemPurchasePrimaryKey> {
   @EmbeddedId
   private SaleEntryItemPurchasePrimaryKey id;
   private String quantity;
}
------

It seems like the problem is the inherited field DomainObjectWithEmbeddedId.id, which is annoted with @EmbeddedId.
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:10:45 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink