Class DAHelper

java.lang.Object
io.odysz.semantic.util.DAHelper

public class DAHelper extends Object
  • Constructor Details

    • DAHelper

      public DAHelper()
  • Method Details

    • getValstr

      public static String getValstr(io.odysz.transact.sql.Transcxt trb, String conn, io.odysz.semantics.meta.TableMeta m, String valfield, Object... kvs) throws SQLException, io.odysz.transact.x.TransException
      Load a field from table m.tbl.
      Parameters:
      trb - transaction builder
      conn -
      m - the table must have a pk.
      valfield -
      kvs -
      Returns:
      field's value in row[kvs[0] = kvs[1], kvs[1] = kvs[2], ...]
      Throws:
      SQLException
      io.odysz.transact.x.TransException
    • getExprstr

      public static Object getExprstr(DATranscxt trb, String connid, io.odysz.semantics.meta.TableMeta m, io.odysz.transact.sql.parts.condition.Funcall valexpr, String as, Object... kvs) throws io.odysz.transact.x.TransException, SQLException
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • loadRecLong

      public static long loadRecLong(DATranscxt trb, String conn, io.odysz.semantics.meta.TableMeta m, String recId, String field) throws SQLException, io.odysz.transact.x.TransException
      Deprecated.
      call getValong(DATranscxt, String, TableMeta, String, String...), e.g. getValong(t, m, target-field, m.pk, recId, ...).
      Parameters:
      trb -
      conn -
      m -
      recId -
      field -
      Returns:
      long value
      Throws:
      SQLException
      io.odysz.transact.x.TransException
    • getValong

      public static long getValong(DATranscxt trb, String conn, io.odysz.semantics.meta.TableMeta m, String field, String... kvs) throws SQLException, io.odysz.transact.x.TransException
      Throws:
      SQLException
      io.odysz.transact.x.TransException
    • updateFieldByPk

      public static io.odysz.semantics.SemanticObject updateFieldByPk(DATranscxt trb, String conn, io.odysz.semantics.meta.TableMeta m, String recId, String vfield, Object v, io.odysz.semantics.IUser usr) throws io.odysz.transact.x.TransException, SQLException
      Commit to DB(conn) as user usr, with SQL:
      update m.tbl set field = v where m.pk = recId
      Parameters:
      trb -
      conn -
      m -
      recId -
      vfield -
      v -
      usr -
      Returns:
      affected rows
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • updateFieldsByPk

      public static io.odysz.semantics.SemanticObject updateFieldsByPk(io.odysz.semantics.IUser usr, DATranscxt trb, String conn, io.odysz.semantics.meta.TableMeta m, String recId, Object... nvs) throws io.odysz.transact.x.TransException, SQLException
      Commit to DB(conn) as user usr, with SQL:
      update m.tbl set field = v where m.pk = recId
      Parameters:
      usr -
      trb -
      conn -
      m -
      recId -
      nvs - n-v pairs
      Returns:
      updating result
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • updateFieldWhereEqs

      public static io.odysz.semantics.SemanticObject updateFieldWhereEqs(DATranscxt trb, String conn, io.odysz.semantics.IUser usr, io.odysz.semantics.meta.TableMeta m, String field, Object v, Object... whereqs) throws io.odysz.transact.x.TransException, SQLException
      Commit to DB(conn) as user usr, with SQL:
      update m.tbl set field = v where whereqs[0] = whereqs[1] and whereqs[2] = whereqs[3] ...
      Parameters:
      trb -
      conn -
      usr -
      m -
      field -
      v -
      whereqs -
      Returns:
      affected rows
      Throws:
      io.odysz.transact.x.TransException
      SQLException
      Since:
      2.0.0
    • count_

      public static int count_(DATranscxt b, String conn, String tbl, String field, String v) throws SQLException, io.odysz.transact.x.TransException
      Returns:
      count
      Throws:
      SQLException
      io.odysz.transact.x.TransException
    • count

      public static int count(DATranscxt b, String conn, String tbl, Object... kvs) throws SQLException, io.odysz.transact.x.TransException
      Throws:
      SQLException
      io.odysz.transact.x.TransException
    • insert

      public static io.odysz.semantics.SemanticObject insert(io.odysz.semantics.IUser usr, DATranscxt t0, String conn, io.odysz.semantics.meta.TableMeta snm, Object... nvs) throws io.odysz.transact.x.TransException, SQLException
      Throws:
      io.odysz.transact.x.TransException
      SQLException
    • getEntityById

      public static AnResultset getEntityById(DATranscxt b, io.odysz.semantics.meta.TableMeta m, String id) throws SQLException, io.odysz.transact.x.TransException
      Throws:
      SQLException
      io.odysz.transact.x.TransException