Question

I have a parent class with the following annotations

@PersistenceCapable(table = "my_parent_table", objectIdClass = Myclass.PK.class, detachable = "true", identityType = IdentityType.APPLICATION)
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
@Discriminator(strategy = DiscriminatorStrategy.VALUE_MAP, column = "discriminator", value = "0")

Now all my child classes have the following annotation, except that the value attribute for the @Discriminator annotation varies of course and also except for the table attribute for the @PersistanceCapable annotation.

@PersistenceCapable(detachable = "true", table = "my_table")
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
@Discriminator(value = "1")

And through a DAO class, annotated with @Persistence, I'm using the following method as a PoC

    public List<MyParentClass> test() {
        PersistenceManager pm = null;
        try {
            pm = getPM();
            Query q = pm.newQuery(MyParentClass.class);
            return (List<MyParentClass>) q.execute();
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return null;
        } finally {
            pm.close();
        }
    }
Was it helpful?

Solution

I checked the logs as DataNucleus suggested in his comment. I shouldn't have used a @Discriminatorfor the parent class.

I'm not sure if I may use a @Discriminator for child classes but I figured a way to drop using it totally for the whole hierarchy so different records for different classes are differentiated by nature.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top