Skip to content

Conversation

@schauder
Copy link
Contributor

No description provided.

@gregturn gregturn closed this Nov 27, 2017
@gregturn gregturn deleted the issue/DATAJDBC-150 branch November 27, 2017 17:45
@gregturn
Copy link
Contributor

Resolved via 0b2708f

mp911de added a commit that referenced this pull request Feb 21, 2022
DatabaseClient now supports named parameters prefixed with a colon such as :name in addition to database-native bind markers. Named parameters thus are supported in annotated repository query methods which also increases portability of queries across database vendors.

Named parameter support unrolls collection arguments to reduce the need for argument-specific SQL statements:

db.execute()
    .sql("SELECT id, name, state FROM table WHERE age IN (:ages)")
    .bind("ages", Arrays.asList(35, 50));

Results in a query: SELECT id, name, state FROM table WHERE age IN (35, 50)

Collection arguments containing nested object arrays can be used to use select lists:

List<Object[]> tuples = new ArrayList<>();
tuples.add(new Object[] {"John", 35});
tuples.add(new Object[] {"Ann",  50});

db.execute()
    .sql("SELECT id, name, state FROM table WHERE (name, age) IN (:tuples)")
    .bind("tuples", tuples);

translates to: SELECT id, name, state FROM table WHERE (name, age) IN (('John', 35), ('Ann', 50))

Original pull request: #47.
mp911de pushed a commit that referenced this pull request Feb 21, 2022
Formatting.
Made Tests simpler and stricter by using `containsExactly`.
Added @test annotation to ignored database specific tests so they actually show up as ignored.

Original pull request: #47.
mp911de added a commit that referenced this pull request Feb 21, 2022
Original pull request: #47.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants