[FEAT] start working on reverse @ManyToMany
This commit is contained in:
parent
e2ee68cc03
commit
37f1362c3c
@ -108,13 +108,18 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
@NotNull final String name,
|
@NotNull final String name,
|
||||||
@NotNull final CountInOut count,
|
@NotNull final CountInOut count,
|
||||||
final QueryOptions options) throws Exception {
|
final QueryOptions options) throws Exception {
|
||||||
|
final ManyToMany manyToMany = AnnotationTools.getManyToMany(field);
|
||||||
final String linkTableName = generateLinkTableName(tableName, name);
|
final String linkTableName = generateLinkTableName(tableName, name);
|
||||||
final Class<?> objectClass = (Class<?>) ((ParameterizedType) field.getGenericType())
|
final Class<?> objectClass = (Class<?>) ((ParameterizedType) field.getGenericType())
|
||||||
.getActualTypeArguments()[0];
|
.getActualTypeArguments()[0];
|
||||||
final String tmpVariable = "tmp_" + Integer.toString(count.value);
|
final String tmpVariable = "tmp_" + Integer.toString(count.value);
|
||||||
querySelect.append(" (SELECT GROUP_CONCAT(");
|
querySelect.append(" (SELECT GROUP_CONCAT(");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
|
if (manyToMany.mappedBy() == null) {
|
||||||
querySelect.append(".object2Id ");
|
querySelect.append(".object2Id ");
|
||||||
|
} else {
|
||||||
|
querySelect.append(".object1Id ");
|
||||||
|
}
|
||||||
if ("sqlite".equals(ConfigBaseVariable.getDBType())) {
|
if ("sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||||
querySelect.append(", ");
|
querySelect.append(", ");
|
||||||
} else {
|
} else {
|
||||||
@ -143,11 +148,19 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
|||||||
querySelect.append(" = ");
|
querySelect.append(" = ");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
querySelect.append(".");
|
querySelect.append(".");
|
||||||
|
if (manyToMany.mappedBy() == null) {
|
||||||
querySelect.append("object1Id ");
|
querySelect.append("object1Id ");
|
||||||
|
} else {
|
||||||
|
querySelect.append("object2Id ");
|
||||||
|
}
|
||||||
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||||
querySelect.append(" GROUP BY ");
|
querySelect.append(" GROUP BY ");
|
||||||
querySelect.append(tmpVariable);
|
querySelect.append(tmpVariable);
|
||||||
|
if (manyToMany.mappedBy() == null) {
|
||||||
querySelect.append(".object1Id");
|
querySelect.append(".object1Id");
|
||||||
|
} else {
|
||||||
|
querySelect.append(".object2Id");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
querySelect.append(") AS ");
|
querySelect.append(") AS ");
|
||||||
querySelect.append(name);
|
querySelect.append(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user