davidkron opened a new issue, #14521:
URL: https://github.com/apache/grails-core/issues/14521

   I wanted to create a hierarchy of classes with the **table per subclass** 
strategy (see example below). Since we have common functionality in our domain 
classes, we have an **abstract base class** that is extended by all other 
domain classes.
   
   Note: if I remove the abstract base class from the hierarchy, the 
application starts and works as expected.
   
   ### Task List
   
   - [x] Steps to reproduce provided
   - [x] Stacktrace (if present) provided
   - [x] Example that reproduces the problem uploaded to Github
   - [x] Full description of the issue provided (see below)
   
   ### Steps to Reproduce
   Put the following classes in the grails domain folder.
   ```
   abstract class BaseEntity {
     // common behavior for all entities in the application
   }
   
   class X extends BaseEntity {
       static mapping = {
           tablePerHierarchy false
       }
   }
   
   class A extends X {
       static hasMany = [bs: B]
   }
   
   class B extends X {
       A a
   }
   ```
   
   ### Expected Behaviour
   I think the given class hierarchy is not that complex and pretty common and 
should just work.
   
   ### Actual Behaviour
   An exception is thrown during application boot.
   ```
   Caused by: org.hibernate.MappingException: Entities [example.A] and 
[example.B] are mapped with the same discriminator value 'null'.
        at 
org.hibernate.persister.entity.SingleTableEntityPersister.addSubclassByDiscriminatorValue(SingleTableEntityPersister.java:450)
        at 
org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:424)
        ... 57 common frames omitted
   ```
   
   ### Environment Information
   
   - **Operating System**: Windows 10
   - **GORM Version:** 7.0.1
   - **Grails Version (if using Grails):** Grails 3.3.10
   - **JDK Version:** 8
   
   ### Example Application
   The 4 given classes under "Steps to Reproduce" are sufficient to reproduce 
the exception in a newly created grails application.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to