Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
javab_20230928
Commits
3a49d5c3
Commit
3a49d5c3
authored
Nov 07, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jakieś dopiski
parent
44dc5a66
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
Repository5.java
...znie/src/main/java/com/example/demo/data/Repository5.java
+6
-4
Inject3.java
...src/main/java/com/example/demo/wstrzykiwanie/Inject3.java
+1
-1
No files found.
PC31-SpringTechnicznie/src/main/java/com/example/demo/data/Repository5.java
View file @
3a49d5c3
...
...
@@ -27,10 +27,12 @@ public interface Repository5 extends JpaRepository<Employee, Integer> {
List
<
Employee
>
findBySalary
(
BigDecimal
min
,
BigDecimal
max
);
@Query
(
nativeQuery
=
true
,
value
=
"SELECT first_name || ' ' || last_name"
+
" FROM employees"
+
" WHERE extract(year FROM hire_date) = :year"
+
" ORDER BY last_name"
)
value
=
"""
SELECT first_name || ' ' || last_name
FROM employees
WHERE extract(year FROM hire_date) = :year
ORDER BY last_name
"""
)
List
<
String
>
namesByYear
(
int
year
);
// W ramach takiego interfejsu można też pisać metody z własną implementacją.
...
...
PC31-SpringTechnicznie/src/main/java/com/example/demo/wstrzykiwanie/Inject3.java
View file @
3a49d5c3
...
...
@@ -17,7 +17,7 @@ public class Inject3 {
// Zauważmy, że ta klasa nie jest już poprawnym "JavaBean", bo nie posiada konstruktora domyślnego.
// Adnotacja Autowired tym razem nie jest potrzebna.
public
Inject3
(
Komponent
komponent
,
Repo
repo
)
{
System
.
out
.
println
(
"KONSTRUKTOR Inject3(komponent, repo)
"
);
System
.
out
.
println
(
"KONSTRUKTOR Inject3(komponent, repo)
; komponent = "
+
komponent
);
this
.
komponent
=
komponent
;
this
.
repo
=
repo
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment