Skip to content

distinction between typed (selection) queries and update queries #718

@gavinking

Description

@gavinking

We currently don't have a very clean or well-defined split between TypedQuery, which I claim should always represent a select query, and update/delete queries, which I claim should always be executed via the untyped supertype Query.

This sorta reflects the fact that TypedQuery was hacked on later in JPA 2.0.

In fact, it's quite arguable that Persistence 3.2 lets you execute a named update query using TypedQuery<Void> obtained via a TypedQueryReference. I don't recall if we really intended that, but even if we did, I don't think it's great.

As a first step to cleaning this up I would:

  1. override and deprecate executeUpdate() on TypedQuery
  2. introduce the (unparameterized) type QueryReference to represent untyped queries

A further optional step might be to introduce a dedicated interface for executing update/delete queries (the equivalent of Hibernate's MutationQuery) which subtracts all the operations of Query which are only relevant to select queries. I'm not sure of the best way to do this, and I'm concerned about introducing an explosion of createQuery() operations, so perhaps it's not worth going this far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions