Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-152

Warn or throw an exception when a persistence unit has multiple named queries with the same name

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • jpa, logging, query
    • None

    Description

      The JPA spec makes it quite easy for uses to create multiple named queries with the same name. The problem stems from named queries being declared as part of an entity either via annotations or nested xml, but the name space for these queries is not scoped to the entity but scoped to the whole persistence unit. This problem is compounded due to the ease at which the persistence unit is easily expanded with orm.xml files and with annotated beans.

      I propose that we throw a deployment exception when the combined entity mapping xml files and listed classes contain multiple named queries with the same name. If after deployment, we discover another annotate bean that creates a conflict, we should log a ERROR and take extra cautions to not override the existing in place query with the newly discovered one, as this could drastically change the behavior of an application at runtime.

      Alternatively, we could just log warnings, but I would prefer a deployment exception as it guarantees I'm not running with a randomly selected set or queries.

      Attachments

        Activity

          People

            curtisr7 Richard G. Curtis
            dain Dain Sundstrom
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: