本文整理汇总了Java中com.mysema.query.types.path.NumberPath类的典型用法代码示例。如果您正苦于以下问题:Java NumberPath类的具体用法?Java NumberPath怎么用?Java NumberPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NumberPath类属于com.mysema.query.types.path包,在下文中一共展示了NumberPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: datasetColumnAliases
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
private List<Tuple> datasetColumnAliases(Transaction tx, Expression<?> datasetRel, NumberPath<Integer> datasetRelId, StringPath datasetRelName, int datasetId) {
final QSourceDatasetVersionColumn sourceDatasetVersionColumnSub = new QSourceDatasetVersionColumn("source_dataset_version_column_sub");
final QSourceDatasetVersion sourceDatasetVersionSub = new QSourceDatasetVersion("source_dataset_version_sub");
return tx.query().from(datasetRel)
.join(dataset).on(dataset.id.eq(datasetRelId))
.join(sourceDatasetVersionColumn).on(sourceDatasetVersionColumn.name.eq(datasetRelName))
.join(sourceDatasetVersion).on(sourceDatasetVersion.id.eq(sourceDatasetVersionColumn.sourceDatasetVersionId)
.and(dataset.sourceDatasetId.eq(sourceDatasetVersion.sourceDatasetId)))
.where(datasetRelId.eq(datasetId))
.where(new SQLSubQuery().from(sourceDatasetVersionColumnSub)
.join(sourceDatasetVersionSub).on(sourceDatasetVersionSub.id.eq(sourceDatasetVersionColumnSub.sourceDatasetVersionId))
.where(sourceDatasetVersionColumnSub.name.eq(sourceDatasetVersionColumn.name))
.where(sourceDatasetVersionColumnSub.sourceDatasetVersionId.gt(sourceDatasetVersionColumn.sourceDatasetVersionId))
.where(sourceDatasetVersionSub.sourceDatasetId.eq(dataset.sourceDatasetId))
.notExists())
.where(sourceDatasetVersionColumn.alias.isNotNull())
.orderBy(sourceDatasetVersionColumn.index.desc())
.list(sourceDatasetVersionColumn.name, sourceDatasetVersionColumn.alias);
}
示例2: createNumberExpressionEqual
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* Return where clause expression for number properties by casting it to
* string before check its value.
* <p/>
* Querydsl Expr:
* {@code entityPath.fieldName.stringValue() eq searchStr
* Database operation:
* {@code str(entity.fieldName) = searchStr
* <p/>
* Like operation is case sensitive.
*
* @param entityPath Full path to entity and associations. For example:
* {@code Pet} , {@code Pet.owner}
* @param fieldName Property name in the given entity path. For example:
* {@code weight} in {@code Pet} entity, {@code age} in
* {@code Pet.owner} entity.
* @param searchStr the value to find, may be null
* @return PredicateOperation
*/
@SuppressWarnings("unchecked")
public static <T, N extends java.lang.Number & java.lang.Comparable<?>> BooleanExpression createNumberExpressionEqual(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr,
ConversionService conversionService) {
if (StringUtils.isEmpty(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
TypeDescriptor strDesc = STRING_TYPE_DESCRIPTOR;
if (conversionService != null) {
try {
return numberExpression.eq((N) conversionService.convert(
searchStr, strDesc, descriptor));
}
catch (ConversionException ex) {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
示例3: createNumberExpressionEqual
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("unchecked")
public <T, N extends Number & Comparable<?>> BooleanExpression createNumberExpressionEqual(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr) {
if (StringUtils.isEmpty(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
TypeDescriptor strDesc = STRING_TYPE_DESCRIPTOR;
if (conversionService != null) {
try {
return numberExpression.eq((N) conversionService.convert(
searchStr, strDesc, descriptor));
}
catch (ConversionException ex) {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
return numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
示例4: testQuery
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Test
@Transactional
public void testQuery() throws Exception {
springfieldQueryTemplateRepository.save(new SpringfieldQueryTemplate("a", 1));
springfieldQueryTemplateRepository.save(new SpringfieldQueryTemplate("b", 2));
springfieldQueryTemplateRepository.save(new SpringfieldQueryTemplate("c", 3));
List<SpringfieldQueryTemplate> result = springfieldQueryTemplateRepository.execute(
new TemplateCallback<List<SpringfieldQueryTemplate>, EntityManager>() {
public List<SpringfieldQueryTemplate> doInTemplate(EntityManager em) {
//Using QueryDsl
SpringfieldQueryTemplate alias = Alias.alias(SpringfieldQueryTemplate.class, "foo");
EntityPath<SpringfieldQueryTemplate> foo = Alias.$(alias);
StringPath fooName = Alias.$(alias.getName());
NumberPath<Integer> fooAge = Alias.$(alias.getAge());
JPAQuery query = new JPAQuery(em);
query.from(foo);
query.where(fooName.eq("a"));
query.where(fooAge.eq(1));
return query.list(foo);
}
});
Assert.assertEquals(result.size(), 1);
}
示例5: intPath
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Test
public void intPath() {
SimplePath<Tuple> aaa = PathExpressions.simplePath("aaa");
NumberPath<Integer> bbb = PathExpressions.intPath(aaa, "bbb");
assertEquals(Integer.class, bbb.getType());
assertEquals("bbb", bbb.getMetadata().getName());
assertEquals(aaa, bbb.getMetadata().getParent());
}
示例6: longPath
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Test
public void longPath() {
SimplePath<Tuple> aaa = PathExpressions.simplePath("aaa");
NumberPath<Long> bbb = PathExpressions.longPath(aaa, "bbb");
assertEquals(Long.class, bbb.getType());
assertEquals("bbb", bbb.getMetadata().getName());
assertEquals(aaa, bbb.getMetadata().getParent());
}
示例7: decimalPath
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Test
public void decimalPath() {
SimplePath<Tuple> aaa = PathExpressions.simplePath("aaa");
NumberPath<BigDecimal> bbb = PathExpressions.decimalPath(aaa, "bbb");
assertEquals(BigDecimal.class, bbb.getType());
assertEquals("bbb", bbb.getMetadata().getName());
assertEquals(aaa, bbb.getMetadata().getParent());
}
示例8: StructureProcessor
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
StructureProcessor(
StringPath styleIdentificationPath,
StringPath styleNamePath,
StringPath childLayerIdentificationPath,
StringPath parentLayerIdentificationPath,
NumberPath<Integer> layerOrderPath,
BooleanPath cyclePath) {
this.styleIdentificationPath = styleIdentificationPath;
this.styleNamePath = styleNamePath;
this.childLayerIdentificationPath = childLayerIdentificationPath;
this.parentLayerIdentificationPath = parentLayerIdentificationPath;
this.layerOrderPath = layerOrderPath;
this.cyclePath = cyclePath;
}
示例9: createNumericExpression
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* Return an expression for {@code entityPath.fieldName} (for Numerics) with
* the {@code operator} or "equal" by default.
* <p/>
* Expr: {@code entityPath.fieldName eq searchObj}
*
* @param entityPath
* @param fieldName
* @param searchObj
* @param operator
* @param fieldType
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static <T> BooleanExpression createNumericExpression(
PathBuilder<T> entityPath, String fieldName, Object searchObj,
String operator, Class<?> fieldType) {
NumberPath numberExpression = null;
if (BigDecimal.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<BigDecimal>) fieldType);
}
else if (BigInteger.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<BigInteger>) fieldType);
}
else if (Byte.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Byte>) fieldType);
}
else if (Double.class.isAssignableFrom(fieldType)
|| double.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Double>) fieldType);
}
else if (Float.class.isAssignableFrom(fieldType)
|| float.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Float>) fieldType);
}
else if (Integer.class.isAssignableFrom(fieldType)
|| int.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Integer>) fieldType);
}
else if (Long.class.isAssignableFrom(fieldType)
|| long.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Long>) fieldType);
}
else if (Short.class.isAssignableFrom(fieldType)
|| short.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Short>) fieldType);
}
if (numberExpression != null) {
Number value = NumberUtils.createNumber((String) searchObj);
if (StringUtils.equalsIgnoreCase(operator, OPERATOR_GOE)) {
return numberExpression.goe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "gt")) {
return numberExpression.gt(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "like")) {
return numberExpression.like((String) searchObj);
}
else if (StringUtils.equalsIgnoreCase(operator, OPERATOR_LOE)) {
return numberExpression.loe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "lt")) {
return numberExpression.lt(value);
}
}
return entityPath.get(fieldName).eq(searchObj);
}
示例10: createNumberExpression
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* Return where clause expression for number properties by casting it to
* string before check its value.
* <p/>
* Querydsl Expr:
* {@code entityPath.fieldName.stringValue() like ('%' + searchStr + '%')}
* Database operation:
* {@code str(entity.fieldName) like ('%' + searchStr + '%')}
* <p/>
* Like operation is case sensitive.
*
* @param entityPath Full path to entity and associations. For example:
* {@code Pet} , {@code Pet.owner}
* @param fieldName Property name in the given entity path. For example:
* {@code weight} in {@code Pet} entity, {@code age} in
* {@code Pet.owner} entity.
* @param searchStr the value to find, may be null
* @return PredicateOperation
*/
public static <T, N extends java.lang.Number & java.lang.Comparable<?>> BooleanExpression createNumberExpression(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr,
ConversionService conversionService) {
if (StringUtils.isBlank(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
BooleanExpression expression = null;
if (conversionService != null) {
try {
Object number = conversionService.convert(searchStr,
STRING_TYPE_DESCRIPTOR, descriptor);
if (number == null) {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
else {
String toSearch = number.toString();
if (number instanceof BigDecimal
&& ((BigDecimal) number).scale() > 1) {
// For bigDecimal trim 0 in decimal part
toSearch = StringUtils.stripEnd(toSearch, "0");
if (StringUtils.endsWith(toSearch, ".")) {
// prevent "#." strings
toSearch = toSearch.concat("0");
}
}
expression = numberExpression.stringValue().like(
"%".concat(toSearch).concat("%"));
}
}
catch (ConversionException e) {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
return expression;
}
示例11: createNumericExpression
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public <T> BooleanExpression createNumericExpression(
PathBuilder<T> entityPath, String fieldName, Object searchObj,
String operator, Class<?> fieldType) {
NumberPath numberExpression = null;
if (BigDecimal.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<BigDecimal>) fieldType);
}
else if (BigInteger.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<BigInteger>) fieldType);
}
else if (Byte.class.isAssignableFrom(fieldType)) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Byte>) fieldType);
}
else if (Double.class.isAssignableFrom(fieldType)
|| double.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Double>) fieldType);
}
else if (Float.class.isAssignableFrom(fieldType)
|| float.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Float>) fieldType);
}
else if (Integer.class.isAssignableFrom(fieldType)
|| int.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Integer>) fieldType);
}
else if (Long.class.isAssignableFrom(fieldType)
|| long.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Long>) fieldType);
}
else if (Short.class.isAssignableFrom(fieldType)
|| short.class == fieldType) {
numberExpression = entityPath.getNumber(fieldName,
(Class<Short>) fieldType);
}
if (numberExpression != null) {
Number value = NumberUtils.createNumber((String) searchObj);
if (StringUtils.equalsIgnoreCase(operator, OPERATOR_GOE)) {
return numberExpression.goe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "gt")) {
return numberExpression.gt(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "like")) {
return numberExpression.like((String) searchObj);
}
else if (StringUtils.equalsIgnoreCase(operator, OPERATOR_LOE)) {
return numberExpression.loe(value);
}
else if (StringUtils.equalsIgnoreCase(operator, "lt")) {
return numberExpression.lt(value);
}
}
return entityPath.get(fieldName).eq(searchObj);
}
示例12: createNumberExpression
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public <T, N extends Number & Comparable<?>> BooleanExpression createNumberExpression(
PathBuilder<T> entityPath, String fieldName, Class<N> fieldType,
TypeDescriptor descriptor, String searchStr) {
if (StringUtils.isBlank(searchStr)) {
return null;
}
NumberPath<N> numberExpression = entityPath.getNumber(fieldName,
fieldType);
BooleanExpression expression = null;
if (conversionService != null) {
try {
Object number = conversionService.convert(searchStr,
STRING_TYPE_DESCRIPTOR, descriptor);
if (number == null) {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
else {
String toSearch = number.toString();
if (number instanceof BigDecimal
&& ((BigDecimal) number).scale() > 1) {
// For bigDecimal trim 0 in decimal part
toSearch = StringUtils.stripEnd(toSearch, "0");
if (StringUtils.endsWith(toSearch, ".")) {
// prevent "#." strings
toSearch = toSearch.concat("0");
}
}
expression = numberExpression.stringValue().like(
"%".concat(toSearch).concat("%"));
}
}
catch (ConversionException e) {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
}
else {
expression = numberExpression.stringValue().like(
"%".concat(searchStr).concat("%"));
}
return expression;
}
示例13: IsQueryResultWithColumnRange
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
public IsQueryResultWithColumnRange(NumberPath<T> column, T min, T max) {
super();
this.column = column;
this.min = min;
this.max = max;
}
示例14: hasColumnRange
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Factory
public static <T extends Number & Comparable<T>, Q extends ProjectableQuery<?>> Matcher<? super Q> hasColumnRange(
NumberPath<T> column, T min, T max) {
return new IsQueryResultWithColumnRange<>(column, min, max);
}
示例15: hasColumnMax
import com.mysema.query.types.path.NumberPath; //导入依赖的package包/类
@Factory
public static <T extends Number & Comparable<T>, Q extends ProjectableQuery<?>> Matcher<? super Q> hasColumnMax(
NumberPath<T> column, Matcher<? super T> maxMatcher) {
return IsQueryResultWithColumnMax.hasColumnMax(column, maxMatcher);
}