Class JpaDB<T extends ActiveRecordBase>

java.lang.Object
sk.iway.iwcm.database.JpaDB<T>
Direct Known Subclasses:
CaptchaDictionaryDB, CookieManagerDB, DocNoteDB, DocumentsDB, DomainLimitsDB, EnumerationDataDB, EnumerationTypeDB, ExportDatDB, FileArchivatorDB, FileArchivCategoryNodeDB, FileHistoryDB, FormsDB, ForumDB, GdprRegExpDB, InsertScriptDB, InsertScriptDocDB, InsertScriptGroupDB, PasswordsHistoryDB, PermissionGroupDB, PersistentCacheDB, QuestionsAnswersDB, ReservationObjectPriceDB, ReservationObjectTimesDB, TemplatesGroupDB, ToDoDB

public class JpaDB<T extends ActiveRecordBase> extends Object
JpaDB.java Basic read, update, insert and delete operations for a JPA bean
  • Field Details

    • dbName

      protected String dbName
  • Constructor Details

    • JpaDB

      public JpaDB(Class<T> clazz)
    • JpaDB

      public JpaDB(Class<T> clazz, String dbName)
  • Method Details

    • of

      public static <T extends ActiveRecordBase> JpaDB<T> of(Class<T> clazz)
    • getById

      public T getById(int id)
    • getById

      public T getById(Long id)
    • getAll

      public List<T> getAll()
    • getCount

      public long getCount()
    • getValues

      public List getValues(String property)
    • save

      public boolean save(T... entities)
    • delete

      public boolean delete(T... entities)
    • deleteByIds

      public void deleteByIds(int... ids)
    • find

      public List<T> find(String property, Object value)
    • findFirst

      public T findFirst(String property, Object value)
    • findByProperties

      public List<T> findByProperties(Pair<String,? extends Object>... properties)
    • findFirstByProperties

      public T findFirstByProperties(Pair<String,? extends Object>... properties)
    • findBy

      public List<T> findBy(JpaTools.Condition... conditions)
      Vrati zoznam objektov, ktore splnaju zadane podmienky. Priklad: class ExampleDB extends JpaDB<ExampleBean> { public List<ExampleBean> getExamples(String nameFilter) { return findBy(filterSubstring("name"), nameFilter); } }
      Parameters:
      conditions -
      Returns:
    • findBy

      public List<T> findBy(Integer maxRows, JpaTools.Condition... conditions)
    • filterNull

      protected static JpaTools.Condition filterNull(String property)
    • filterNotNull

      protected static JpaTools.Condition filterNotNull(String property)
    • filterEquals

      protected static JpaTools.Condition filterEquals(String property, String value)
      Podmienka je splnena, ak filter nie je zadany (null alebo prazdny) alebo ak sa hodnota vlastnosti rovna danej hodnote.
      Parameters:
      property -
      value -
      Returns:
    • filterEquals

      protected static JpaTools.Condition filterEquals(String property, int value)
    • filterEquals

      protected static JpaTools.Condition filterEquals(String property, boolean value)
    • filterSubstring

      protected static JpaTools.Condition filterSubstring(String property, String substring)
      Podmienka je splnena, ak filter nie je zadany (null alebo prazdny) alebo ak hodnota vlastnosti obsahuje tento podretazec.
      Parameters:
      property - nazov vlastnosti
      substring - hladany podretazec
      Returns:
    • filterSubstringIgnoringCase

      protected static JpaTools.Condition filterSubstringIgnoringCase(String property, String substring)
      Podmienka je splnena, ak filter nie je zadany (null alebo prazdny) alebo ak hodnota vlastnosti obsahuje tento podretazec, nezalezi na velkosti pismen.
      Parameters:
      property - nazov vlastnosti
      substring - hladany podretazec
      Returns:
    • filterIn

      public static JpaTools.Condition filterIn(String property, Collection<String> values)
      Podmienka je splnena, ak filter nie je zadany (null alebo prazdny zoznam) alebo ak hodnota vlastnosti je v tomto zozname.
      Parameters:
      property -
      values -
      Returns:
    • filterNotIn

      protected static JpaTools.Condition filterNotIn(String property, Collection<String> values)
      Podmienka je splnena, ak filter nie je zadany (null alebo prazdny zoznam) alebo ak hodnota vlastnosti nie je v tomto zozname.
      Parameters:
      property -
      values -
      Returns:
    • filterBetween

      protected static JpaTools.Condition filterBetween(String property, int minValue, int maxValue)
      Podmienka je splnena, ak hodnota vlastnosti je v danom intervale (vratane oboch krajnych hodnot).
      Parameters:
      property -
      minValue -
      maxValue -
      Returns:
    • filterBetween

      protected static JpaTools.Condition filterBetween(String property, BigDecimal minValue, BigDecimal maxValue)
    • filterBetween

      protected static JpaTools.Condition filterBetween(String property, Date minValue, Date maxValue)
    • and

      public static org.eclipse.persistence.expressions.Expression and(org.eclipse.persistence.expressions.Expression e1, org.eclipse.persistence.expressions.Expression e2)
      Spojenie dvoch Expression cez "AND", zabezpecene proti hodnotam "null". Pomocka pre metody "filter..."
      Parameters:
      e1 -
      e2 -
      Returns:
    • or

      public static org.eclipse.persistence.expressions.Expression or(org.eclipse.persistence.expressions.Expression e1, org.eclipse.persistence.expressions.Expression e2)
      Spojenie dvoch Expression cez "OR", zabezpecene proti hodnotam "null". Pomocka pre metody "filter..."
      Parameters:
      e1 -
      e2 -
      Returns:
    • getResultList

      public static <T> List<T> getResultList(javax.persistence.Query q)