Change in ovirt-engine[master]: core: Example: Use UUID for handling database Guids

amureini at redhat.com amureini at redhat.com
Thu Jul 4 08:48:54 UTC 2013


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 <amureini at redhat.com>
---
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 <amureini at redhat.com>
Gerrit-Reviewer: Alissa Bonas <abonas at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Greg Padgett <gpadgett at redhat.com>
Gerrit-Reviewer: Liran Zelkha <liran.zelkha at gmail.com>
Gerrit-Reviewer: Maor Lipchuk <mlipchuk at redhat.com>
Gerrit-Reviewer: Mike Kolesnik <mkolesni at redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofrenkel at redhat.com>
Gerrit-Reviewer: Tal Nisan <tnisan at redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzaslavs at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server



More information about the Engine-commits mailing list