congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DbOomQuery.query
Code IndexAdd Tabnine to your IDE (free)

How to use
query
method
in
jodd.db.oom.DbOomQuery

Best Java code snippets using jodd.db.oom.DbOomQuery.query (Showing top 20 results out of 315)

origin: oblac/jodd

/**
 * Finds list of entities matching given criteria.
 */
@SuppressWarnings({"unchecked"})
public <E> List<E> find(final Object criteria) {
  return query(dbOom.entities().find(criteria)).autoClose().list(criteria.getClass());
}
origin: oblac/jodd

/**
 * Finds one entity for given criteria.
 */
@SuppressWarnings({"unchecked"})
public <E> E findOne(final Object criteria) {
  return (E) query(dbOom.entities().find(criteria)).autoClose().find(criteria.getClass());
}
origin: oblac/jodd

/**
 * Finds related entity.
 */
public <E> List<E> findRelated(final Class<E> target, final Object source) {
  return query(dbOom.entities().findForeign(target, source)).autoClose().list(target);
}
origin: oblac/jodd

/**
 * List all entities.
 */
public <E> List<E> listAll(final Class<E> target) {
  return query(dbOom.entities().from(target)).autoClose().list(target);
}
origin: oblac/jodd

/**
 * Counts number of all entities.
 */
public long count(final Class entityType) {
  return query(dbOom.entities().count(entityType)).autoClose().executeCount();
}
origin: oblac/jodd

/**
 * Finds single entity by matching property.
 */
public <E> E findOneByProperty(final Class<E> entityType, final String name, final Object value) {
  return query(dbOom.entities().findByColumn(entityType, name, value)).autoClose().find(entityType);
}
origin: oblac/jodd

/**
 * Decreases a property.
 */
public <ID> void decreaseProperty(final Class entityType, final ID id, final String name, final Number delta) {
  query(dbOom.entities().increaseColumn(entityType, id, name, delta, false)).autoClose().executeUpdate();
}
origin: oblac/jodd

/**
 * Finds list of entities matching given criteria.
 */
public <E> List<E> find(final Class<E> entityType, final Object criteria) {
  return query(dbOom.entities().find(entityType, criteria)).autoClose().list(entityType);
}
origin: oblac/jodd

/**
 * Deleted single entity by its id.
 */
public <ID> void deleteById(final Class entityType, final ID id) {
  query(dbOom.entities().deleteById(entityType, id)).autoClose().executeUpdate();
}
origin: oblac/jodd

/**
 * Simply inserts object into the database.
 */
public void save(final Object entity) {
  final DbQuery q = query(dbOom.entities().insert(entity));
  q.autoClose().executeUpdate();
}
origin: oblac/jodd

/**
 * Updates single entity.
 */
public void update(final Object entity) {
  query(dbOom.entities().updateAll(entity)).autoClose().executeUpdate();
}
origin: oblac/jodd

/**
 * Finds single entity by its id.
 */
public <E, ID> E findById(final Class<E> entityType, final ID id) {
  return query(dbOom.entities().findById(entityType, id)).autoClose().find(entityType);
}
origin: oblac/jodd

/**
 * Increases a property.
 */
public <ID> void increaseProperty(final Class entityType, final ID id, final String name, final Number delta) {
  query(dbOom.entities().increaseColumn(entityType, id, name, delta, true)).autoClose().executeUpdate();
}
origin: oblac/jodd

/**
 * Updates single property in database and in the bean.
 */
public <E> E updateProperty(final E entity, final String name, final Object newValue) {
  query(dbOom.entities().updateColumn(entity, name, newValue)).autoClose().executeUpdate();
  BeanUtil.declared.setProperty(entity, name, newValue);
  return entity;
}
origin: oblac/jodd

/**
 * Updates property in the database by storing the current property value.
 */
public <E> E updateProperty(final E entity, final String name) {
  Object value = BeanUtil.declared.getProperty(entity, name);
  query(dbOom.entities().updateColumn(entity, name, value)).autoClose().executeUpdate();
  return entity;
}
origin: oblac/jodd

@Test
void testMapRows2Types_entityAware() {
  DbOomQuery q = DbOomQuery.query(sql(TSQL));
  List<Girl2> result2 = q.withHints("g", "g.boys").entityAwareMode(true).list(Girl2.class, Boy.class);
  assertEquals(2, result2.size());
  Girl2 girl1 = result2.get(0);
  Girl2 girl3 = result2.get(1);
  assertNotNull(girl1.getBoys());
  assertEquals(2, girl1.getBoys().size());
  assertNotNull(girl3.getBoys());
  assertEquals(1, girl3.getBoys().size());
}
origin: oblac/jodd

@Test
void testMapRows2Types_entityAware_List() {
  DbOomQuery q = DbOomQuery.query(sql(TSQL));
  List<Girl2> result2 = q.withHints("g", "g.boys").entityAwareMode(true).list(1, Girl2.class, Boy.class);
  assertEquals(1, result2.size());
  Girl2 girl1 = result2.get(0);
  assertNotNull(girl1.getBoys());
  assertEquals(2, girl1.getBoys().size());
}
origin: oblac/jodd

@Test
void testMapRows2Types_entityAware_List_LEFT() {
  DbOomQuery q = DbOomQuery.query(sql(TSQL_LEFT));
  List<Girl2> result2 = q.withHints("g", "g.boys").entityAwareMode(true).list(2, Girl2.class, Boy.class);
  assertEquals(2, result2.size());
  Girl2 girl0 = result2.get(0);
  Girl2 girl1 = result2.get(1);
  assertNull(girl0.getBoys());
  assertNotNull(girl1.getBoys());
  assertEquals(2, girl1.getBoys().size());
}
origin: oblac/jodd

@Test
void testMapRows2Types_entityAware_Find() {
  DbOomQuery q = DbOomQuery.query(sql(TSQL));
  Girl2 girl1 = q.withHints("g", "g.boys").entityAwareMode(true).find(Girl2.class, Boy.class);
  assertNotNull(girl1.getBoys());
  assertEquals(2, girl1.getBoys().size());
}
origin: oblac/jodd

@Test
void testMapRows2Types_entityAware_Find_LEFT() {
  DbOomQuery q = DbOomQuery.query(sql(TSQL_LEFT));
  Girl2 girl0 = q.withHints("g", "g.boys").entityAwareMode(true).find(Girl2.class, Boy.class);
  assertNull(girl0.getBoys());
}
jodd.db.oomDbOomQueryquery

Popular methods of DbOomQuery

  • close
    Closes results set or whole query.
  • list
    Iterates result set, maps rows to classes and populates resulting array list.
  • executeCount
  • closeResultSet
  • find
  • getGeneratedColumns
  • iterate
  • listSet
  • withHints
    Specifies multiple hints for the query.
  • <init>
  • autoClose
  • createResultSetMapper
    Factory for result sets mapper.
  • autoClose,
  • createResultSetMapper,
  • execute,
  • executeAndBuildResultSetMapper,
  • executeUpdate,
  • findGeneratedColumns,
  • getGeneratedColumnNames,
  • init,
  • resolveColumnDbSqlType

Popular in Java

  • Reactive rest calls using spring rest template
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now