Skip to content

Commit

Permalink
Fix getConstants usage in tests #713
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Apr 15, 2014
1 parent cb9c977 commit bc30eff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@
*/
package com.mysema.query.jpa;

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.junit.Test;
import org.junit.runner.RunWith;

import antlr.RecognitionException;
import antlr.TokenStreamException;

import com.mysema.query.jpa.domain.Cat;
import com.mysema.query.jpa.domain.QCat;
import com.mysema.query.jpa.hibernate.HibernateDeleteClause;
Expand All @@ -36,6 +23,17 @@
import com.mysema.query.jpa.hibernate.HibernateUtil;
import com.mysema.query.types.EntityPath;
import com.mysema.testutil.HibernateTestRunner;
import org.hibernate.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

@RunWith(HibernateTestRunner.class)
public class IntegrationBase extends ParsingTest {
Expand All @@ -49,8 +47,10 @@ protected QueryHelper query() {
public void parse() throws RecognitionException, TokenStreamException {
try {
System.out.println("query : " + toString().replace('\n', ' '));
Query query = session.createQuery(toString());
HibernateUtil.setConstants(query, getConstants(),getMetadata().getParams());
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
serializer.serialize(getMetadata(), false, null);
Query query = session.createQuery(serializer.toString());
HibernateUtil.setConstants(query, serializer.getConstantToLabel(), getMetadata().getParams());
query.list();
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
*/
package com.mysema.query.jpa;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import org.junit.Rule;
import org.junit.rules.MethodRule;
import org.junit.runner.RunWith;

import antlr.RecognitionException;
import antlr.TokenStreamException;

import com.mysema.query.JPAProviderRule;
import com.mysema.query.TargetRule;
import com.mysema.query.jpa.impl.JPAProvider;
import com.mysema.query.jpa.impl.JPAUtil;
import com.mysema.testutil.JPATestRunner;
import org.junit.Rule;
import org.junit.rules.MethodRule;
import org.junit.runner.RunWith;

import javax.persistence.EntityManager;
import javax.persistence.Query;

@RunWith(JPATestRunner.class)
public class JPAIntegrationBase extends ParsingTest {
Expand All @@ -51,8 +49,10 @@ public void parse() throws RecognitionException, TokenStreamException {
System.out.println("query : " + toString().replace('\n', ' '));

// create Query and execute it
Query query = em.createQuery(toString());
JPAUtil.setConstants(query, getConstants(),getMetadata().getParams());
JPQLSerializer serializer = new JPQLSerializer(templates);
serializer.serialize(getMetadata(), false, null);
Query query = em.createQuery(serializer.toString());
JPAUtil.setConstants(query, serializer.getConstantToLabel(), getMetadata().getParams());
try {
query.getResultList();
} catch (Exception e) {
Expand Down

0 comments on commit bc30eff

Please sign in to comment.