mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
Merge pull request #1091 from querydsl/i1088
Fix collection serialization in case constructs
This commit is contained in:
commit
7d5e82eac9
@ -13,12 +13,13 @@
|
||||
*/
|
||||
package com.mysema.query.jpa;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.metamodel.EntityType;
|
||||
import javax.persistence.metamodel.Metamodel;
|
||||
import javax.persistence.metamodel.SingularAttribute;
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@ -282,7 +283,20 @@ public class JPQLSerializer extends SerializerBase<JPQLSerializer> {
|
||||
@Override
|
||||
public void visitConstant(Object constant) {
|
||||
if (inCaseOperation && templates.isCaseWithLiterals()) {
|
||||
visitLiteral(constant);
|
||||
if (constant instanceof Collection) {
|
||||
append("(");
|
||||
boolean first = true;
|
||||
for (Object o : (Collection)constant) {
|
||||
if (!first) {
|
||||
append(", ");
|
||||
}
|
||||
visitLiteral(o);
|
||||
first = false;
|
||||
}
|
||||
append(")");
|
||||
} else {
|
||||
visitLiteral(constant);
|
||||
}
|
||||
} else {
|
||||
boolean wrap = templates.wrapConstant(constant);
|
||||
if (wrap) {
|
||||
|
||||
@ -13,15 +13,19 @@
|
||||
*/
|
||||
package com.mysema.query;
|
||||
|
||||
import java.io.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mysema.query.Target.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import antlr.RecognitionException;
|
||||
import antlr.TokenStreamException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mysema.commons.lang.Pair;
|
||||
@ -42,11 +46,9 @@ import com.mysema.query.types.expr.*;
|
||||
import com.mysema.query.types.path.*;
|
||||
import com.mysema.query.types.template.NumberTemplate;
|
||||
import com.mysema.testutil.ExcludeIn;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import static com.mysema.query.Target.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import antlr.RecognitionException;
|
||||
import antlr.TokenStreamException;
|
||||
|
||||
/**
|
||||
* @author tiwe
|
||||
@ -313,6 +315,14 @@ public abstract class AbstractJPATest {
|
||||
.otherwise(4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Case3() {
|
||||
query().from(cat)
|
||||
.list(Expressions.cases()
|
||||
.when(cat.toes.in(2, 3)).then(cat.id.multiply(cat.toes))
|
||||
.otherwise(4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Cast() {
|
||||
List<Cat> cats = query().from(cat).list(cat);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user