-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/example/demo/AnonymousLambdaParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.demo; | ||
|
||
import org.springframework.jdbc.core.simple.JdbcClient; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.sql.DataSource; | ||
|
||
@Component | ||
class AnonymousLambdaParameters implements LanguageDemonstrationRunner { | ||
|
||
private final JdbcClient db; | ||
|
||
AnonymousLambdaParameters(DataSource db) { | ||
this.db = JdbcClient.create(db); | ||
} | ||
|
||
record Customer(Integer id, String name) { | ||
} | ||
|
||
@Override | ||
public void run() throws Throwable { | ||
var allCustomers = this.db.sql("select * from customer ") | ||
.query((rs, _) -> new Customer(rs.getInt("id"), rs.getString("name"))) | ||
.list(); | ||
System.out.println("all: " + allCustomers); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
spring.application.name=demo | ||
spring.threads.virtual.enabled=true | ||
spring.threads.virtual.enabled=true | ||
spring.sql.init.mode=always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
insert into customer(name ) values ('Brian'); | ||
insert into customer(name ) values ('Thomas'); | ||
insert into customer(name ) values ('Alina'); | ||
insert into customer(name ) values ('Stuart'); | ||
insert into customer(name ) values ('Sharat'); | ||
insert into customer(name ) values ('James'); | ||
insert into customer(name ) values ('Ron'); | ||
insert into customer(name ) values ('Billy'); | ||
insert into customer(name ) values ('Heather'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
create table if not exists customer | ||
( | ||
id serial primary key, | ||
name text not null | ||
); |