Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink mapping question

Hello Leon,
Are you using the @Inheritance annotation? Set this annotation on your CatalogProduct Entity. That will tell EclipseLink that this is the root of your inheritance.
--Gordon

Leon Derks wrote:
Hello Tom,

Thanks for your answer,

I have to other concrete classes that inherit from my CatalogProduct class, so the @DiscriminatorColumn(name="PRODUCT_TYPE") is needed in my CatalogProduct in order to instantiate the concrete subclass.

I temporary solved the issue by removing the BaseEntity and adding an extra id variable in each Entity class.

But after that, it is still not working with Eclipselink. The strange thing is that it is working with Hibernate.

See my previous mail for more details.

Leon

Tom Ware wrote:
Hi Leon,

I suspect that removing the @DiscriminatorColumn(name="PRODUCT_TYPE") annotation will solve your problem.

In this case it looks to me like you are trying to inherit an attribute rather than implement inheritance. The DiscriminatorColumn is used for JPA Inheritance.

-Tom

Leon Derks wrote:
Hello

I have the following problem:

I defined a BaseEntity for all my Entity classes. This BaseEntity class contains only the id.
In this way I don't need to define id variables in every Entity class.

I have a CatalogProduct class which extends the BaseEntity class.
But when I run the query for an entity, for example: em.createQuery("select p from CatalogProduct p").getResultList(), it always tries to select from the BaseEntity table which doesn't exist.

What is causing the problem?

@MappedSuperclass
public abstract class BaseEntity {
     @Id
   @Column(name="id")
   private long id;

   public long getId() {
       return id;
   }

}

@Entity
@Table(schema="PLI", name = "PLI_CATALOG_PRODUCTS")
@DiscriminatorColumn(name="PRODUCT_TYPE")
public abstract class CatalogProduct extends BaseEntity{
  ......
  ......
}

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



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


Back to the top