KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a requirement to have an abstract superclass. I have 6 subclasses for that abstract superclass. I mapped them with the SINGLE_TABLE inheritance strategy in JPA. In another POJO I have a one to many relationship with these 1+6 classes. @OneToMany(mappedBy = "mSearchPreference", cascade = CascadeType.ALL) private Set<SearchCriteria> mSearchCriteria; here "SearchCriteria" is the abstract class. @Entity @Table(name = "SRCH_CRTR_T", schema = "LPEW") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "SRCH_DISCRIMINATOR_CDE", discriminatorType = DiscriminatorType.STRING) @org.hibernate.annotations.ForceDiscriminator public abstract class SearchCriteria extends BaseDBObject implements Comparable<SearchCriteria> and it has 6 concrete subclasses classes like @Entity @DiscriminatorValue("DATE") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) public class SearchCriteriaDateRange extends SearchCriteria I can insert the values into the table, but when I am retrieving I get an error: Caused by: org.hibernate.WrongClassException: Object with id: 261 was not of the specified subclass: com.lmig.lit.lpew.model.criteria.SearchCriteria (Discriminator: DATE ) at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1453) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1284) at org.hibernate.loader.Loader.getRow(Loader.java:1206) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580) at org.hibernate.loader.L 10:57:44,786 INFO [STDOUT] oader.doQuery(Loader.java:701) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.loadCollection(Loader.java:1994) at org.hibernate.loader.collection.BatchingCollectionInitializer.initialize(BatchingCollectionInitializer.java:52)
Tags (comma-separated)
Save Edits
Cancel