Allon Mureinik has submitted this change and it was merged.

Change subject: core: Example: Use UUID for handling database Guids
......................................................................


core: Example: Use UUID for handling database Guids

The Postgres JDBC Driver natively supports the java.util.UUID type as a
representation of a database uuid, in both directions -
1. ResultSet#getObject(int) and ResultSet#getObject(String) return a
   UUID instance when applied to a uuid column.
2. PreparedStatement#setObject(int, Object) can receive a UUID and apply
   it to a uuid column.

Using the proper type has several benefits:
1. Save the CPU operations on UUID.getString() and Guid(String) when
   using ResultSet.getObject(int) or ResultSet.getObject(String).
2. Save the CPU operations on Guid.toString() and having the DATABASE
   convert a String passed to a PreparedStatement to a uuid.
3. Bind Guids as native uuids instead of varchars, making sure that
   indexes will be used in the query.

This patch is an example how this should be done, presented on
StoragePoolIsoMapDAODbFacadeImpl.
This DAO was chosen since it's one of the simplest DAOs and requires the
least amount of code changes. If this patch will be accepted, subsequent
patches will apply the same changes to the other DAOs.

Change-Id: I4d30e1ab7303ecad68dbc9005ac5c6ef733f1707
Signed-off-by: Allon Mureinik <[email protected]>
---
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/CustomMapSqlParameterSource.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/BaseDAODbFacade.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolIsoMapDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dal/dbbroker/CustomMapSqlParameterSourceTest.java
4 files changed, 53 insertions(+), 4 deletions(-)

Approvals:
  Allon Mureinik: Verified; Looks good to me, approved


-- 
To view, visit http://gerrit.ovirt.org/16281
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4d30e1ab7303ecad68dbc9005ac5c6ef733f1707
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Alissa Bonas <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Greg Padgett <[email protected]>
Gerrit-Reviewer: Liran Zelkha <[email protected]>
Gerrit-Reviewer: Maor Lipchuk <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Omer Frenkel <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to