Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19327

camel-jpa: Single result

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.20.4, 4.0-M3
    • 3.21.0, 4.0-RC1, 4.0.0
    • camel-jpa
    • None
    • Unknown

    Description

      A common use case is that a query (or a find) should return exactly one object, and any other result is to be considered an error. camel-sql supports thehttps://issues.apache.org/jira/browse/CAMEL-19327# outputType=SelectOne option which will cause the component to throw an exception if the query does not return a single row. camel-jpa does not have such an option and thus user must manually check for body size.

      This PR addresses that. It adds a boolean option singleResult, which, if set to true:

      • in case of a query will cause the component to put the single fetched object into the message body, not in a List, or throw an exception otherwise
      • in case of a find, if no object is found the component will throw an exception rather than put null into the body

      it has no effect on updates, and doesn't alter the consumer.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jsz Jacek SzymaƄski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: