added oracle JPA tests

This commit is contained in:
Timo Westkämper 2012-02-20 21:53:36 +02:00
parent 57d45add41
commit c0b1d618de
9 changed files with 61 additions and 21 deletions

View File

@ -53,7 +53,8 @@ public class FilterFactory {
return rv;
}
public <A> Collection<BooleanExpression> collection(CollectionExpressionBase<?,A> expr, CollectionExpression<?,A> other, A knownElement){
public <A> Collection<BooleanExpression> collection(CollectionExpressionBase<?,A> expr,
CollectionExpression<?,A> other, A knownElement){
HashSet<BooleanExpression> rv = new HashSet<BooleanExpression>();
rv.add(expr.contains(knownElement));
rv.add(expr.isEmpty());
@ -64,7 +65,8 @@ public class FilterFactory {
return rv;
}
public <A> Collection<BooleanExpression> array(ArrayExpression<A> expr, ArrayExpression<A> other, A knownElement){
public <A> Collection<BooleanExpression> array(ArrayExpression<A> expr, ArrayExpression<A> other,
A knownElement){
HashSet<BooleanExpression> rv = new HashSet<BooleanExpression>();
if (!module.equals(Module.RDFBEAN)){
rv.add(expr.size().gt(0));
@ -73,7 +75,8 @@ public class FilterFactory {
return rv;
}
private <A extends Comparable<A>> Collection<BooleanExpression> comparable(ComparableExpression<A> expr, ComparableExpression<A> other, A knownValue){
private <A extends Comparable<A>> Collection<BooleanExpression> comparable(ComparableExpression<A> expr,
ComparableExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.addAll(exprFilters(expr, other, knownValue));
rv.add(expr.gt(other));
@ -92,7 +95,8 @@ public class FilterFactory {
}
private <A extends Comparable<A>> Collection<BooleanExpression> dateOrTime(TemporalExpression<A> expr, TemporalExpression<A> other, A knownValue){
private <A extends Comparable<A>> Collection<BooleanExpression> dateOrTime(TemporalExpression<A> expr,
TemporalExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.add(expr.after(other));
rv.add(expr.after(knownValue));
@ -102,7 +106,8 @@ public class FilterFactory {
}
@SuppressWarnings("unchecked")
public <A extends Comparable> Collection<BooleanExpression> date(DateExpression<A> expr, DateExpression<A> other, A knownValue){
public <A extends Comparable> Collection<BooleanExpression> date(DateExpression<A> expr,
DateExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.addAll(comparable(expr, other, knownValue));
rv.addAll(dateOrTime(expr, other, knownValue));
@ -113,7 +118,8 @@ public class FilterFactory {
}
@SuppressWarnings("unchecked")
public <A extends Comparable> Collection<BooleanExpression> dateTime(DateTimeExpression<A> expr, DateTimeExpression<A> other, A knownValue){
public <A extends Comparable> Collection<BooleanExpression> dateTime(DateTimeExpression<A> expr,
DateTimeExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.addAll(comparable(expr, other, knownValue));
rv.addAll(dateOrTime(expr, other, knownValue));
@ -139,7 +145,8 @@ public class FilterFactory {
return rv;
}
private <A> Collection<BooleanExpression> exprFilters(SimpleExpression<A> expr, SimpleExpression<A> other, A knownValue){
private <A> Collection<BooleanExpression> exprFilters(SimpleExpression<A> expr,
SimpleExpression<A> other, A knownValue){
HashSet<BooleanExpression> rv = new HashSet<BooleanExpression>();
rv.add(expr.eq(other));
rv.add(expr.eq(knownValue));
@ -149,14 +156,16 @@ public class FilterFactory {
return rv;
}
public <A, Q extends SimpleExpression<A>> Collection<BooleanExpression> list(ListPath<A, Q> expr, ListExpression<A, Q> other, A knownElement){
public <A, Q extends SimpleExpression<A>> Collection<BooleanExpression> list(ListPath<A, Q> expr,
ListExpression<A, Q> other, A knownElement){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.addAll(collection(expr, other, knownElement));
rv.add(expr.get(0).eq(knownElement));
return rv;
}
public <K,V> Collection<BooleanExpression> map(MapExpressionBase<K,V,?> expr, MapExpression<K,V> other, K knownKey, V knownValue) {
public <K,V> Collection<BooleanExpression> map(MapExpressionBase<K,V,?> expr,
MapExpression<K,V> other, K knownKey, V knownValue) {
HashSet<BooleanExpression> rv = new HashSet<BooleanExpression>();
rv.add(expr.containsKey(knownKey));
rv.add(expr.containsValue(knownValue));
@ -171,7 +180,8 @@ public class FilterFactory {
}
@SuppressWarnings("unchecked")
public <A extends Number & Comparable<A>> Collection<BooleanExpression> numeric(NumberExpression<A> expr, NumberExpression<A> other, A knownValue){
public <A extends Number & Comparable<A>> Collection<BooleanExpression> numeric(NumberExpression<A> expr,
NumberExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
for (NumberExpression<?> num : projections.numeric(expr, other, knownValue, true)){
rv.add(num.lt(expr));
@ -209,7 +219,8 @@ public class FilterFactory {
return rv;
}
public <A> Collection<BooleanExpression> pathFilters(SimpleExpression<A> expr, SimpleExpression<A> other, A knownValue){
public <A> Collection<BooleanExpression> pathFilters(SimpleExpression<A> expr,
SimpleExpression<A> other, A knownValue){
return Arrays.<BooleanExpression>asList(
expr.isNull(),
expr.isNotNull()
@ -217,7 +228,8 @@ public class FilterFactory {
}
@SuppressWarnings("unchecked")
public Collection<BooleanExpression> string(StringExpression expr, StringExpression other, String knownValue){
public Collection<BooleanExpression> string(StringExpression expr, StringExpression other,
String knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
if (expr instanceof Path && other instanceof Path){
rv.addAll(pathFilters(expr, other, knownValue));
@ -294,7 +306,8 @@ public class FilterFactory {
}
@SuppressWarnings("unchecked")
public <A extends Comparable> Collection<BooleanExpression> time(TimeExpression<A> expr, TimeExpression<A> other, A knownValue){
public <A extends Comparable> Collection<BooleanExpression> time(TimeExpression<A> expr,
TimeExpression<A> other, A knownValue){
List<BooleanExpression> rv = new ArrayList<BooleanExpression>();
rv.addAll(comparable(expr, other, knownValue));
rv.addAll(dateOrTime(expr, other, knownValue));

View File

@ -281,7 +281,8 @@ public class MatchingFiltersFactory {
return rv;
}
public Collection<BooleanExpression> string(StringExpression expr, StringExpression other, String knownValue){
public Collection<BooleanExpression> string(StringExpression expr, StringExpression other,
String knownValue){
HashSet<BooleanExpression> rv = new HashSet<BooleanExpression>();
rv.addAll(string(expr, other));
rv.addAll(string(expr, StringConstant.create(knownValue)));

View File

@ -13,7 +13,6 @@
*/
package com.mysema.query._oracle;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import com.mysema.query.AbstractHibernateTest;
@ -21,7 +20,6 @@ import com.mysema.query.Target;
import com.mysema.testutil.HibernateConfig;
import com.mysema.testutil.HibernateTestRunner;
@Ignore // FIXME
@RunWith(HibernateTestRunner.class)
@HibernateConfig("oracle.properties")
public class OracleStandardTest extends AbstractHibernateTest{
@ -30,5 +28,10 @@ public class OracleStandardTest extends AbstractHibernateTest{
protected Target getTarget() {
return Target.ORACLE;
}
@Override
public void JoinEmbeddable() {
// for some reasonable not supported
}
}

View File

@ -31,7 +31,6 @@ public class ExtendedDerbyDialect extends DerbyDialect{
private static final CastFunction castFunction = new CastFunction(){
@Override
@SuppressWarnings("unchecked")
public String render(Type columnType, List args, SessionFactoryImplementor factory) {
if (args.get(1).equals("string")){
return super.render(columnType, Arrays.<Object>asList("char("+args.get(0)+")",args.get(1)), factory);

View File

@ -0,0 +1,20 @@
package com.mysema.query.jpa.support;
import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StandardBasicTypes;
/**
* @author tiwe
*
*/
public class ExtendedOracleDialect extends Oracle10gDialect {
public ExtendedOracleDialect() {
// there fail otherwise with the time datatype
registerFunction( "second", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "to_number(to_char(?1,'SS'))") );
registerFunction( "minute", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "to_number(to_char(?1,'MI'))") );
registerFunction( "hour", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "to_number(to_char(?1,'HH24'))") );
}
}

View File

@ -1,5 +1,6 @@
## MySQL
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
#hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.dialect=com.mysema.query.jpa.support.ExtendedOracleDialect
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:xe
hibernate.connection.username=querydsl

View File

@ -367,7 +367,8 @@ public class LuceneSerializer {
}
@SuppressWarnings({"unchecked"})
protected Query range(Path<?> leftHandSide, String field, @Nullable Expression<?> min, @Nullable Expression<?> max, boolean minInc, boolean maxInc, QueryMetadata metadata) {
protected Query range(Path<?> leftHandSide, String field, @Nullable Expression<?> min,
@Nullable Expression<?> max, boolean minInc, boolean maxInc, QueryMetadata metadata) {
if (min != null && Number.class.isAssignableFrom(min.getType()) || max != null
&& Number.class.isAssignableFrom(max.getType())) {
Class<? extends Number> numType = (Class) (min != null ? min.getType() : max.getType());

View File

@ -61,7 +61,8 @@ public final class LuceneUtils {
* @param prefixLength
* @return
*/
public static BooleanExpression fuzzyLike(Path<String> path, String value, float minimumSimilarity, int prefixLength){
public static BooleanExpression fuzzyLike(Path<String> path, String value,
float minimumSimilarity, int prefixLength){
Term term = new Term(path.getMetadata().getExpression().toString(), value);
return new QueryElement(new FuzzyQuery(term, minimumSimilarity, prefixLength));
}

View File

@ -44,7 +44,8 @@ public final class ResultIterator<T> implements CloseableIterator<T> {
private final Transformer<Document,T> transformer;
public ResultIterator(ScoreDoc[] scoreDocs, int offset, Searcher searcher, @Nullable FieldSelector fieldSelector, Transformer<Document, T> transformer) {
public ResultIterator(ScoreDoc[] scoreDocs, int offset, Searcher searcher,
@Nullable FieldSelector fieldSelector, Transformer<Document, T> transformer) {
this.scoreDocs = scoreDocs;
this.cursor = offset;
this.searcher = searcher;