Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_20230801
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
alx_20230801
Commits
a982e996
Commit
a982e996
authored
Aug 03, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rozdzielenie insert i update
parent
759ab54c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
Ogloszenia.java
...zeniaSerwer/src/main/java/ogloszenia/soap/Ogloszenia.java
+25
-2
No files found.
OgloszeniaSerwer/src/main/java/ogloszenia/soap/Ogloszenia.java
View file @
a982e996
...
@@ -41,11 +41,34 @@ public class Ogloszenia {
...
@@ -41,11 +41,34 @@ public class Ogloszenia {
}
}
}
}
public
void
save
(
public
void
update
(
@WebParam
(
name
=
"ogloszenie"
)
OgloszenieSamochodowe
ogloszenie
)
throws
BladBazyDanych
,
NieznanyRekord
{
// W tej wersji zakładamy, że obiekt ma podane id i nadpisujemy istniejące.
// W tym przypadku nie trzeba dawać informacji zwrotnej.
try
(
DostepDoBazySqlite
db
=
DostepDoBazySqlite
.
newSQLite
())
{
db
.
beginTransaction
();
OgloszenieDAO
dao
=
db
.
newOgloszenieDAO
();
boolean
sukces
=
dao
.
update
(
ogloszenie
);
if
(!
sukces
)
{
throw
new
NieznanyRekord
(
"Brak ogłoszenia nr "
+
ogloszenie
.
getIdOgloszenia
());
}
db
.
endTransaction
(
true
);
}
}
@WebResult
(
name
=
"new-id"
)
public
int
insert
(
@WebParam
(
name
=
"ogloszenie"
)
OgloszenieSamochodowe
ogloszenie
)
throws
BladBazyDanych
{
@WebParam
(
name
=
"ogloszenie"
)
OgloszenieSamochodowe
ogloszenie
)
throws
BladBazyDanych
{
// W tej wersji zawsze dodajemy nowy rekord.
// W razie, gdyby klient przysłał ogłoszenie z ustawionym id, to my i tak to id zignorujemy.
// W tej wersji w odpowiedzi wysyłamy id nowego rekordu, aby klient dowiedział się jakie ono jest.
ogloszenie
.
setIdOgloszenia
(
null
);
try
(
DostepDoBazySqlite
db
=
DostepDoBazySqlite
.
newSQLite
())
{
try
(
DostepDoBazySqlite
db
=
DostepDoBazySqlite
.
newSQLite
())
{
db
.
beginTransaction
();
OgloszenieDAO
dao
=
db
.
newOgloszenieDAO
();
OgloszenieDAO
dao
=
db
.
newOgloszenieDAO
();
dao
.
save
(
ogloszenie
);
dao
.
insertNew
(
ogloszenie
);
db
.
endTransaction
(
true
);
return
ogloszenie
.
getIdOgloszenia
();
}
}
}
}
}
}
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