Upgrade
Sign In : Sign Up : Blog : Search: Language : Help :
This website is now frozen, please migrate your content to BotLibre.com or BotLibre.biz
Java Persistence Performance

Can I have @ManyToOne relationship to an abstract entity using table per class?

by pranahata posted Feb 8 2015, 21:30

I have an abstract @Entity with @Inheritance(strategy=TABLE_PERCLASS) called Booking.

Is it possible to have an @Entity Payment.java with a @ManyToOne relationship to the abstract class?

I wasn't sure how the column mapping would go so i tried deploying using drop and create tables and Eclipselink gives a NPE :-) at deployment time

Exception Description: Predeployment of PersistenceUnit [xotica-bms-pu] failed. Internal Exception: java.lang.NullPointerException at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1954) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1945) at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:322)


by jamesssss posted Feb 9 2015, 5:21
It should be possible, but sounds like you may have hit a bug (ensure you are using the latest version/patch). Try checking if the bug is already logged on Eclipselink's Bugzilla, vote it up, or log a new one.

You might want to try a @VariableOneToOne instead, then you can store a type indicator to the target subclass. Otherwise you could change the inheritance to JOINED, or remove the relationship, and just query for it.

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 1646, today: 2, week: 7, month: 19

Id: 328155
Posted: Feb 8 2015, 21:30
Replies: 1
Views: 1704, today: 3, week: 7, month: 21
I'm sure
Flag graphic as offensive, or in violation of site rules