Skip to content

Commit

Permalink
querydsl#262 added DataNucleusTemplates
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Oct 31, 2012
1 parent 992e72a commit cca4387
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
target
bin
test-output
.classpath
.project
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2012, Mysema Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mysema.query.jpa;

import com.mysema.query.types.Ops;


public class DataNucleusTemplates extends JPQLTemplates {

public static final JPQLTemplates DEFAULT = new DataNucleusTemplates();

public DataNucleusTemplates() {
this(DEFAULT_ESCAPE);
}

public DataNucleusTemplates(char escape) {
super(escape);
add(Ops.LIKE, "{0} like {1}",1);
add(Ops.MATCHES, "{0} like {1}", 27); // TODO : support real regexes
add(Ops.MATCHES_IC, "{0} like {1}", 27); // TODO : support real regexes

add(Ops.STRING_CONTAINS, "{0} like {%1%}");
add(Ops.STRING_CONTAINS_IC, "{0l} like {%%1%%}");
add(Ops.ENDS_WITH, "{0} like {%1}");
add(Ops.ENDS_WITH_IC, "{0l} like {%%1}");
add(Ops.STARTS_WITH, "{0} like {1%}");
add(Ops.STARTS_WITH_IC, "{0l} like {1%%}");


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.persistence.EntityManager;

import com.google.common.collect.Maps;
import com.mysema.query.jpa.DataNucleusTemplates;
import com.mysema.query.jpa.EclipseLinkTemplates;
import com.mysema.query.jpa.HQLTemplates;
import com.mysema.query.jpa.JPQLTemplates;
Expand All @@ -44,6 +45,7 @@ private static void addMapping(String className, JPQLTemplates templates) {
addMapping("org.hibernate.ejb.HibernateEntityManager", HQLTemplates.DEFAULT);
addMapping("org.eclipse.persistence.jpa.JpaEntityManager", EclipseLinkTemplates.DEFAULT);
addMapping("org.apache.openjpa.persistence.OpenJPAEntityManager", OpenJPATemplates.DEFAULT);
addMapping("org.datanucleus.jpa.EntityManagerImpl", DataNucleusTemplates.DEFAULT);
}

public static JPQLTemplates getTemplates(EntityManager em) {
Expand Down

0 comments on commit cca4387

Please sign in to comment.