You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Entity
@Data
class Image {
private long id;
private long imgId;
private int index;
}
//In service, select all that its index and imgId in a map
HashMap<Integer, Long> usedImageMap = ...
List<Tuple> list = new ArrayList<>();
//But how to initial list from usedImageMap???
queryFactory.selectFrom(qImage)
.where(Expressions.list(qImage.index, qImage.imgId).in(list))
....
Maybe this is a solution, but it is ugly!
usedImageMap.forEach((index, imgId) -> {
list.add(new Tuple() {
@Nullable
@Override
public <T> T get(int i, Class<T> type) {
if (i == 0) return (T)index;
return (T)imgId;
}
@Nullable
@Override
public <T> T get(Expression<T> expr) {
if (expr.equals(qImage.index)) return (T)index;
return (T)imgId;
}
@Override
public int size() {
return 2;
}
@Override
public Object[] toArray() {
return Arrays.asList(index, imgId).toArray();
}
});
});
The text was updated successfully, but these errors were encountered:
Well what happens if qImage.index is not unique? Allow Multimap as input variable as well as a Map? Then what if the input index is actually inversed? How to handle tuples greater than 2, like Expressions.list(a, b, c).in(...)? IMO these decisions will always be use case specific so its not particularly sensible to build something in QueryDSL for this (I am open to suggestions though).
Well what happens if qImage.index is not unique? Allow Multimap as input variable as well as a Map? Then what if the input index is actually inversed? How to handle tuples greater than 2, like Expressions.list(a, b, c).in(...)? IMO these decisions will always be use case specific so its not particularly sensible to build something in QueryDSL for this (I am open to suggestions though).
Maybe this is a solution, but it is ugly!
The text was updated successfully, but these errors were encountered: