Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-6050

Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.1.1, 3.2.x
    • 3.1.0.CR2
    • hibernate
    • None
    • Workaround Exists
    • Hide

      Add
      <discriminator type="string"></discriminator>
      to the parent class mapping

      Show
      Add <discriminator type="string"></discriminator> to the parent class mapping

      1. Create parent class
      2. Create it's subclass
      3. run new hibernate mapping wizard
      4. create console configuration based on the generated files
      5. open session factory:
      Observe the exception below

      org.hibernate.MappingException: No discriminator found for com.pnx.model.hibernate.Person. Discriminator is needed when 'single-table-per-hierarchy' is used and a class has subclasses
      at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:64)
      at org.hibernate.cfg.Configuration.validate(Configuration.java:1149)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1334)
      at org.hibernate.console.ConsoleConfiguration$4.execute(ConsoleConfiguration.java:554)
      at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:63)
      at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:98)
      at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:549)
      at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:43)
      at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:100)
      at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:106)
      at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:234)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

            jpeterka_jira Jiri Peterka (Inactive)
            dgeraskov Dmitry Geraskov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: