Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Qcadoo framework provides a generic crud layer for database entities. All its methods are contained in DataDefinition interface. To get the problem instance of the data definition object You should use DataDefinitionService#get(String,String) method.

CRUD operations

...

example

Code Block
theme
themeEclipse
languagejava
Eclipselinenumberstrue
DataDefinition dd = dataDefinitionService.get("plugin", "model");

Entity e1newEntity = dd.create();
e1newEntity.setField("name", "xxx");
Entity e2savedEntity = dd.save(e1newEntity);

if(e2savedEntity.isValid()) {
    Entity e3existingEntity = dd.get(e2savedEntity.getId());
    e3existingEntity.setField("name", "yyy");
    dd.save(e3existingEntity);

    dd.delete(e3);(existingEntity.getId());
}

Find by HQL example

Please see SearcQueryBuilder documentation for more information.

Code Block
themeEclipse
languagejava
linenumberstrue

DataDefinition dd = dataDefinitionService.get("plugin", "model");

SearchResult result = dd.find("where name = :name").setString("name", "xxx").list();

for(Entity e : result.getEntities()) {
    // ...
}

Find by Criteria example

Please see SearchCriteriaBuilder documentation for more information.

Code Block
themeEclipse
languagejava
linenumberstrue

DataDefinition dd = dataDefinitionService.get("plugin", "model");

SearchResult result = dd.find().add(SearchRestrictions.eq("name", "xxx").list();

for(Entity e : result.getEntities()) {
    // ...
}