Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCK challenge against boolean result of Query #924

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/src/main/java/jakarta/data/repository/Query.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,8 +34,15 @@
*
* <p>The required {@link #value} member specifies the JDQL or JPQL query as a string.</p>
*
* <p>For {@code select} statements, the return type of the query method must be consistent with the type returned by
* the query. For {@code update} or {@code delete} statements, it must be {@code void}, {@code int} or {@code long}.</p>
* <p>For {@code select} statements, the return type of the query method must be
* consistent with the type returned by the query.</p>
*
* <p>For {@code update} or {@code delete} statements, the return value must be one of:</p>
* <ul>
* <li>{@code void}</li>
* <li>{@code int} or {@code long}, where the value is the number of matching entities.
* The value might not be precise on databases that provide eventual consistency.</li>
* </ul>
*
* <p>Compared to SQL, JDQL allows an abbreviated syntax for {@code select} statements:</p>
* <ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
* Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -2462,7 +2462,7 @@ public void testUpdateQueryWithWhereClause() {
float c1yExpected;
double c1xExpected;
try {
assertEquals(true, shared.move(id1, 1.23d, 1.5f));
assertEquals(1, shared.move(id1, 1.23d, 1.5f));
c1yExpected = 3.5f; // 5.25 / 1.5 = 3.5
c1xExpected = 1.23D;
} catch (UnsupportedOperationException x) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -51,7 +51,7 @@ public interface MultipleEntityRepo { // Do not add a primary entity type.
void deleteIfPositiveWithoutReturnRecords();

@Query("UPDATE Coordinate SET x = :newX, y = y / :yDivisor WHERE id = :id")
boolean move(UUID id, double newX, float yDivisor);
int move(UUID id, double newX, float yDivisor);

@Query("WHERE id = ?1")
Optional<Coordinate> withUUID(UUID id);
Expand Down
Loading