Class QRecordEntity

java.lang.Object
com.kingsrook.qqq.backend.core.model.data.QRecordEntity
  • Constructor Details

    • QRecordEntity

      public QRecordEntity()
  • Method Details

    • fromQRecord

      public static <T extends QRecordEntity> T fromQRecord(Class<T> c, QRecord qRecord) throws QException
      Build an entity of this QRecord type from a QRecord
      Throws:
      QException
    • fromQRecord

      public static <T extends QRecordEntity> T fromQRecord(Class<T> c, QRecord qRecord, String fieldNamePrefix) throws QException
      Build an entity of this QRecord type from a QRecord - where the fields for this entity have the given prefix - e.g., if they were selected as part of a join.
      Throws:
      QException
    • registerTable

      public static void registerTable(Class<? extends QRecordEntity> entityClass, QTableMetaData table)
      register a mapping between an entity class and a table that it is associated with.
    • populateFromQRecord

      protected void populateFromQRecord(QRecord qRecord) throws QRuntimeException
      Build an entity of this QRecord type from a QRecord
      Throws:
      QRuntimeException
    • populateFromQRecord

      protected <T extends QRecordEntity> void populateFromQRecord(QRecord qRecord, String fieldNamePrefix) throws QRuntimeException
      Build an entity of this QRecord type from a QRecord - where the fields for this entity have the given prefix - e.g., if they were selected as part of a join.
      Throws:
      QRuntimeException
    • toQRecord

      public QRecord toQRecord() throws QRuntimeException
      Convert this entity to a QRecord. ALL fields in the entity will be set in the QRecord. Note that, if you're using this for an input to the UpdateAction, that this could cause values to be set to null, e.g., if you constructed a entity from scratch, and didn't set all values in it!!
      Throws:
      QRuntimeException
    • toQRecordOnlyChangedFields

      @Deprecated(since="includePrimaryKey param was added") public QRecord toQRecordOnlyChangedFields()
      Deprecated.
      Overload of toQRecordOnlyChangedFields that preserves original behavior of that method, which is, to NOT includePrimaryKey
    • toQRecordOnlyChangedFields

      public QRecord toQRecordOnlyChangedFields(boolean includePrimaryKey)
      Useful for the use-case of: - fetch a QRecord (e.g., QueryAction or GetAction) - build a QRecordEntity out of it - change a field (or two) in it - want to pass it into an UpdateAction, and want to see only the fields that you know you changed get passed in to UpdateAction (e.g., PATCH semantics). But also - per the includePrimaryKey param, include the primaryKey in the records (e.g., to tell the Update which records to update). Also, useful for: - construct new entity, calling setters to populate some fields - pass that entity into
    • getFieldList

      public static List<QRecordEntityField> getFieldList(Class<? extends QRecordEntity> c)
    • getAssociationList

      public static List<QRecordEntityAssociation> getAssociationList(Class<? extends QRecordEntity> c)
    • getQFieldAnnotation

      public static Optional<QField> getQFieldAnnotation(Class<? extends QRecordEntity> c, String fieldName)
    • getQIgnoreAnnotation

      public static Optional<QIgnore> getQIgnoreAnnotation(Class<? extends QRecordEntity> c, String ignoreName)
    • getQAssociationAnnotation

      public static Optional<QAssociation> getQAssociationAnnotation(Class<? extends QRecordEntity> c, String fieldName)
    • getAnnotationOnField

      public static <A extends Annotation> Optional<A> getAnnotationOnField(Class<? extends QRecordEntity> c, Class<A> annotationClass, String fieldName)
    • getFieldNameFromGetter

      public static String getFieldNameFromGetter(Method getter)
    • getTableName

      public static String getTableName(Class<? extends QRecordEntity> entityClass) throws QException
      Throws:
      QException
    • tableName

      public String tableName() throws QException
      named without the 'get' to avoid conflict w/ entity fields named that...
      Throws:
      QException