Improving collection DAO.
This commit is contained in:
@@ -32,16 +32,7 @@ public class DbCollectionDAO implements CollectionDAO {
|
|||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
int playerId = rs.getInt(1);
|
int playerId = rs.getInt(1);
|
||||||
Blob blob = rs.getBlob(2);
|
Blob blob = rs.getBlob(2);
|
||||||
try {
|
playerCollections.put(playerId, extractCollectionAndClose(blob));
|
||||||
InputStream inputStream = blob.getBinaryStream();
|
|
||||||
try {
|
|
||||||
playerCollections.put(playerId, _collectionSerializer.deserializeCollection(inputStream));
|
|
||||||
} finally {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
blob.free();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return playerCollections;
|
return playerCollections;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -66,16 +57,7 @@ public class DbCollectionDAO implements CollectionDAO {
|
|||||||
try {
|
try {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
Blob blob = rs.getBlob(1);
|
Blob blob = rs.getBlob(1);
|
||||||
try {
|
return extractCollectionAndClose(blob);
|
||||||
InputStream inputStream = blob.getBinaryStream();
|
|
||||||
try {
|
|
||||||
return _collectionSerializer.deserializeCollection(inputStream);
|
|
||||||
} finally {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
blob.free();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -90,6 +72,19 @@ public class DbCollectionDAO implements CollectionDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CardCollection extractCollectionAndClose(Blob blob) throws SQLException, IOException {
|
||||||
|
try {
|
||||||
|
InputStream inputStream = blob.getBinaryStream();
|
||||||
|
try {
|
||||||
|
return _collectionSerializer.deserializeCollection(inputStream);
|
||||||
|
} finally {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
blob.free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setPlayerCollection(int playerId, String type, CardCollection collection) throws SQLException, IOException {
|
public void setPlayerCollection(int playerId, String type, CardCollection collection) throws SQLException, IOException {
|
||||||
CardCollection oldCollection = getPlayerCollection(playerId, type);
|
CardCollection oldCollection = getPlayerCollection(playerId, type);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user