...
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 | Eclipse |
---|
language | java | theme |
---|
Eclipse | linenumbers | true |
---|
|
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 |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
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 |
---|
theme | Eclipse |
---|
language | java |
---|
linenumbers | true |
---|
|
DataDefinition dd = dataDefinitionService.get("plugin", "model");
SearchResult result = dd.find().add(SearchRestrictions.eq("name", "xxx").list();
for(Entity e : result.getEntities()) {
// ...
}
|