Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SkuciSe
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tim 2 - 2022
SkuciSe
Commits
4f10a8a8
Commit
4f10a8a8
authored
Sep 11, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slike i lokacija repository - ubacene procedure
parent
7c5d6202
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
SkuciSe/src/main/java/com/example/SkuciSe/repository/LokacijaRepository.java
+10
-4
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
+11
-5
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/repository/LokacijaRepository.java
View file @
4f10a8a8
...
@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.lokacija.Lokacija;
...
@@ -4,6 +4,7 @@ import com.example.SkuciSe.model.lokacija.Lokacija;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.sql.CallableStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -17,11 +18,13 @@ public class LokacijaRepository
...
@@ -17,11 +18,13 @@ public class LokacijaRepository
public
List
<
Lokacija
>
findAll
()
public
List
<
Lokacija
>
findAll
()
{
{
String
sql
=
"
select * from lokacija
"
;
String
sql
=
"
{call findAllLokacija()}
"
;
List
<
Lokacija
>
list
=
new
ArrayList
<
Lokacija
>();
List
<
Lokacija
>
list
=
new
ArrayList
<
Lokacija
>();
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
list
.
add
(
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
)));
list
.
add
(
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
)));
...
@@ -35,10 +38,13 @@ public class LokacijaRepository
...
@@ -35,10 +38,13 @@ public class LokacijaRepository
public
Lokacija
findById
(
int
lokacijaId
)
public
Lokacija
findById
(
int
lokacijaId
)
{
{
String
sql
=
"select * from lokacija where lokacijaid = "
+
lokacijaId
;
String
sql
=
"{ call findLokacijaById(?)}"
;
CallableStatement
stmt
=
null
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
lokacijaId
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
return
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
));
return
new
Lokacija
(
rs
.
getInt
(
"lokacijaid"
),
rs
.
getString
(
"naziv"
));
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/SlikeRepository.java
View file @
4f10a8a8
...
@@ -5,6 +5,7 @@ import com.example.SkuciSe.model.slika.Slika;
...
@@ -5,6 +5,7 @@ import com.example.SkuciSe.model.slika.Slika;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.sql.CallableStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -19,10 +20,13 @@ public class SlikeRepository
...
@@ -19,10 +20,13 @@ public class SlikeRepository
public
List
<
Slika
>
findAllById
(
int
oglasId
)
public
List
<
Slika
>
findAllById
(
int
oglasId
)
{
{
List
<
Slika
>
list
=
new
ArrayList
<
Slika
>();
List
<
Slika
>
list
=
new
ArrayList
<
Slika
>();
String
sql
=
"
select * from slike where oglasid = "
+
oglasId
;
String
sql
=
"
{ call findAllSlikeByOglasId(?)}"
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
CallableStatement
stmt
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
oglasId
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
list
.
add
(
new
Slika
(
rs
.
getInt
(
"slikeId"
),
rs
.
getInt
(
"oglasid"
),
rs
.
getString
(
"slika"
)
));
list
.
add
(
new
Slika
(
rs
.
getInt
(
"slikeId"
),
rs
.
getInt
(
"oglasid"
),
rs
.
getString
(
"slika"
)
));
...
@@ -30,7 +34,6 @@ public class SlikeRepository
...
@@ -30,7 +34,6 @@ public class SlikeRepository
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
return
list
;
return
list
;
}
}
...
@@ -39,10 +42,13 @@ public class SlikeRepository
...
@@ -39,10 +42,13 @@ public class SlikeRepository
List
<
Slika
>
list
=
new
ArrayList
<
Slika
>();
List
<
Slika
>
list
=
new
ArrayList
<
Slika
>();
for
(
Oglas
oglas:
oglasi
)
for
(
Oglas
oglas:
oglasi
)
{
{
String
sql
=
"select * from slike where oglasid = "
+
oglas
.
getOglasId
();
CallableStatement
stmt
=
null
;
String
sql
=
"{call findAllOglasFirstPics(?)}"
;
ResultSet
rs
=
null
;
ResultSet
rs
=
null
;
try
{
try
{
rs
=
dataBase
.
statement
.
executeQuery
(
sql
);
stmt
=
dataBase
.
connection
.
prepareCall
(
sql
);
stmt
.
setInt
(
1
,
oglas
.
getOglasId
());
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
while
(
rs
.
next
())
{
{
list
.
add
(
new
Slika
(
rs
.
getInt
(
"slikeid"
),
rs
.
getInt
(
"oglasid"
),
rs
.
getString
(
"slika"
)));
list
.
add
(
new
Slika
(
rs
.
getInt
(
"slikeid"
),
rs
.
getInt
(
"oglasid"
),
rs
.
getString
(
"slika"
)));
...
...
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