This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch version3
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/version3 by this push:
     new 2263ba4  EMPIREDB-362 small fix
2263ba4 is described below

commit 2263ba4c7fe46be133b62c8a87f305d9a97d796a
Author: Rainer Döbele <[email protected]>
AuthorDate: Thu Jan 27 17:50:34 2022 +0100

    EMPIREDB-362 small fix
---
 .../java/org/apache/empire/samples/db/SampleApp.java     |  2 +-
 .../src/main/java/org/apache/empire/db/DBRecord.java     | 16 ++++++++++++++++
 .../src/main/java/org/apache/empire/db/DBRowSet.java     | 13 +++++--------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
index 724fc15..3f57b71 100644
--- 
a/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
+++ 
b/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
@@ -431,7 +431,7 @@ public class SampleApp
         // Update an Employee with partial record
         // this will only load the EMPLOYEE ID and the PHONE_NUMBER
         DBRecord rec = new DBRecord(context, EMP);
-        EMP.readRecord(rec, DBRecord.key(idEmp), PartialMode.INCLUDE, 
EMP.PHONE_NUMBER);
+        rec.read(DBRecord.key(idEmp), PartialMode.INCLUDE, EMP.PHONE_NUMBER);
         // Set
         rec.setValue(db.EMPLOYEES.PHONE_NUMBER, phoneNumber);
         rec.update();
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
index b2b87a5..0041019 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
@@ -36,6 +36,7 @@ import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
 import org.apache.empire.data.ColumnExpr;
 import org.apache.empire.data.Record;
+import org.apache.empire.db.DBRowSet.PartialMode;
 import org.apache.empire.db.context.DBContextAware;
 import org.apache.empire.db.context.DBRollbackHandler;
 import org.apache.empire.db.exceptions.FieldIsReadOnlyException;
@@ -929,6 +930,21 @@ public class DBRecord extends DBRecordData implements 
DBContextAware, Record, Cl
     {
         rowset.readRecord(this, whereConstraints);
     }
+    
+    /**
+     * Reads a record partially i.e. not with all but just some selected fields
+     * There are two modes:
+     *  1. PartialMode.INCLUDE reads only the fields provided with the column 
list
+     *  2. PartialMode.EXCLUDE reads all but the fields provided with the 
column list
+     * The primary key is always fetched implicitly
+     * @param key the primary key values
+     * @param mode flag whether to include only the given columns or whether 
to add all but the given columns
+     * @param columns the columns to include or exclude (depending on mode)
+     */
+    public void read(Object[] key, PartialMode mode, DBColumn... columns)
+    {
+        rowset.readRecord(this, key, mode, columns);
+    }
 
     /**
      * Updates the record and saves all changes in the database.
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
index b5fcf38..ab17196 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
@@ -694,7 +694,6 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * <P>
      * @param rec the DBRecord object which will hold the record data
      * @param key the primary key values
-     * @param conn a valid JDBC connection.
      */
     public void readRecord(DBRecord rec, Object[] key)
     {
@@ -740,7 +739,6 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Reads the partial record for a given primary key from the database
      * @param rec the DBRecord object which will hold the record data
      * @param key the primary key values
-     * @param conn a valid JDBC connection.
      * @param mode flag whether to include only the given columns or whether 
to add all but the given columns
      * @param columns the columns to include or exclude (depending on mode)
      */
@@ -787,7 +785,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Returns true if the record exists in the database or false otherwise.
      * <P>
      * @param key an array of the primary key columns
-     * @param conn a valid JDBC connection.
+     * @param context the DBContext
      * @return true if the record exists or false otherwise
      */
     public boolean recordExists(Object[] key, DBContext context)
@@ -808,7 +806,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Returns true if the record exists in the database or false otherwise.
      * <P>
      * @param id id of the record
-     * @param conn a valid JDBC connection.
+     * @param context the DBContext
      * @return true if the record exists or false otherwise
      */
     public final boolean recordExists(Object id, DBContext context)
@@ -827,7 +825,6 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * DBErrors.RecordUpdateFailed will be set.  
      * <P>
      * @param rec the DBRecord object. contains all fields and the field 
properties
-     * @param conn a valid JDBC connection.
      */
     public void updateRecord(DBRecord rec)
     {
@@ -998,7 +995,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Deletes a single record from the database.<BR>
      * <P>
      * @param id the record's primary key
-     * @param conn a valid JDBC connection
+     * @param context the DBContext
      */
     public final void deleteRecord(long id, DBContext context)
     {
@@ -1009,7 +1006,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * Deletes all records which reference this table.
      * <P>
      * @param key the key the record to be deleted
-     * @param conn a valid connection
+     * @param context the DBContext
      */
     protected final void deleteAllReferences(Object[] key, DBContext context)
     {
@@ -1041,7 +1038,7 @@ public abstract class DBRowSet extends DBExpr implements 
Entity
      * <P>
      * @param refs the reference columns belonging to the relation
      * @param parentKey the key of the parent element
-     * @param conn a valid connection
+     * @param context the DBContext
      */
     protected void deleteReferenceRecords(DBReference[] refs, Object[] 
parentKey, DBContext context)
     {

Reply via email to