[Entity Manager]
Corretta retrieve entity childs
This commit is contained in:
@@ -2,6 +2,7 @@ package it.integry.ems_model.utility;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems_model.annotation.EntityChild;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.base.EntityPropertyHolder;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
@@ -46,16 +47,16 @@ public class UtilityDB {
|
||||
if (UtilityString.isNullOrEmpty(indexTableDTO.getIndexName()))
|
||||
throw new Exception("Nome indice non trovato");
|
||||
|
||||
if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0 )
|
||||
if (indexTableDTO.getColumnsIndex() == null || indexTableDTO.getColumnsIndex().size() == 0)
|
||||
throw new Exception("Inserire l'elenco delle colonne su ci creare l'indice");
|
||||
|
||||
String sql =
|
||||
Query.format( "SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName());
|
||||
Query.format("SELECT CAST(Count(*) as bit) from sys.sysindexes where name = %s", indexTableDTO.getIndexName());
|
||||
|
||||
boolean existIndex = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
|
||||
List<String> sqls = new ArrayList<>();
|
||||
if ( existIndex) {
|
||||
if (existIndex) {
|
||||
if (indexTableDTO.isOverride()) {
|
||||
sql = String.format("DROP INDEX %s ON dbo.%s", indexTableDTO.getIndexName(), indexTableDTO.getTableName());
|
||||
sqls.add(sql);
|
||||
@@ -86,7 +87,7 @@ public class UtilityDB {
|
||||
sql =
|
||||
String.format(
|
||||
"CREATE %s INDEX %s ON dbo.%s ( %s ) %s %s",
|
||||
indexTableDTO.isClustered()?"CLUSTERED":"NONCLUSTERED",
|
||||
indexTableDTO.isClustered() ? "CLUSTERED" : "NONCLUSTERED",
|
||||
indexTableDTO.getIndexName(),
|
||||
indexTableDTO.getTableName(),
|
||||
indexTableDTO.getColumnsIndexString(),
|
||||
@@ -171,9 +172,14 @@ public class UtilityDB {
|
||||
}
|
||||
}
|
||||
|
||||
final EntityBase tmpChildEntity = rowClass.newInstance();
|
||||
tmpChildEntity.setImportFromParent(testata, true);
|
||||
list = tmpChildEntity.select(conn, whereCond);
|
||||
EntityChild childConstraintDetails = field.getAnnotation(EntityChild.class);
|
||||
if (childConstraintDetails.copyPk()) {
|
||||
list = testata.selectEntityRowList(conn, testata, rowClass, keyType, whereCond);
|
||||
} else {
|
||||
final EntityBase tmpChildEntity = rowClass.newInstance();
|
||||
tmpChildEntity.setImportFromParent(testata, true);
|
||||
list = tmpChildEntity.select(conn, whereCond);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -384,7 +390,7 @@ public class UtilityDB {
|
||||
|
||||
public static String listValueToString(List<String> lista) {
|
||||
lista = Stream.of(lista).map(UtilityDB::valueToString).toList();
|
||||
return StringUtils.join(lista,",");
|
||||
return StringUtils.join(lista, ",");
|
||||
}
|
||||
|
||||
public static int countRow(ResultSet res) {
|
||||
|
||||
Reference in New Issue
Block a user