com.mysema.query.types.Path Java Examples

The following examples show how to use com.mysema.query.types.Path. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PermissionService.java    From spring-boot-practice with Apache License 2.0 6 votes vote down vote up
public Page<Permission> findAllByRoleId(Integer id, Pageable pageable) {
    QRole role = QRole.role;
    Predicate predicate = role.id.eq(id);

    PathBuilder<Permission> builder = new PathBuilder<Permission>(Permission.class, QPermission.permission.getMetadata());
    Querydsl querydsl = new Querydsl(em, builder);

    JPQLQuery countQuery = createQuery(predicate);
    JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate));

    Path<Permission> path = QPermission.permission;
    Long total = countQuery.count();
    List<Permission> content = total > pageable.getOffset() ? query.list(path) : Collections.<Permission>emptyList();

    return new PageImpl<Permission>(content, pageable, total);
}
 
Example #2
Source File: QuerydslSQL.java    From spring-boot-practice with Apache License 2.0 6 votes vote down vote up
private Expression<?> buildOrderPropertyPathFrom(Sort.Order order) {
    Assert.notNull(order, "Order must not be null!");

    PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
    Expression<?> sortPropertyExpression = builder;

    while (path != null) {
        if (!path.hasNext() && order.isIgnoreCase()) {
            // if order is ignore-case we have to treat the last path segment as a String.
            sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
        } else {
            sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
        }

        path = path.next();
    }

    return sortPropertyExpression;
}
 
Example #3
Source File: PermissionService.java    From spring-boot-practice with Apache License 2.0 6 votes vote down vote up
public Page<Permission> findAllByRoleId(Integer id, Pageable pageable) {
    QRole role = QRole.role;
    Predicate predicate = role.id.eq(id);

    PathBuilder<Permission> builder = new PathBuilder<Permission>(Permission.class, QPermission.permission.getMetadata());
    Querydsl querydsl = new Querydsl(em, builder);

    JPQLQuery countQuery = createQuery(predicate);
    JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate));

    Path<Permission> path = QPermission.permission;
    Long total = countQuery.count();
    List<Permission> content = total > pageable.getOffset() ? query.list(path) : Collections.<Permission>emptyList();

    return new PageImpl<Permission>(content, pageable, total);
}
 
Example #4
Source File: QuerydslSQL.java    From spring-boot-practice with Apache License 2.0 6 votes vote down vote up
private Expression<?> buildOrderPropertyPathFrom(Sort.Order order) {
    Assert.notNull(order, "Order must not be null!");

    PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
    Expression<?> sortPropertyExpression = builder;

    while (path != null) {
        if (!path.hasNext() && order.isIgnoreCase()) {
            // if order is ignore-case we have to treat the last path segment as a String.
            sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
        } else {
            sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
        }

        path = path.next();
    }

    return sortPropertyExpression;
}
 
Example #5
Source File: TupleElementKey.java    From SimpleFlatMapper with MIT License 5 votes vote down vote up
private static String getName(Expression<?> expression) {
	if (expression instanceof Path<?>) {
		@SuppressWarnings("rawtypes")
		PathMetadata<?> metadata = ((Path) expression).getMetadata();
		if (metadata.getPathType() == PathType.PROPERTY) {
			return metadata.getElement().toString();
		} else {
			throw new MappingException("Unexpected expression " + expression);
		}
	}  else {
		throw new MappingException("Unexpected expression " + expression);
	}
}
 
Example #6
Source File: EmployeeService.java    From spring-boot-practice with Apache License 2.0 4 votes vote down vote up
public Page<Employee> findAll(Pageable pageable) {
    Predicate predicate = QEmployee.employee.name.startsWith("e");

    PathBuilder<Employee> builder = new PathBuilder<>(Employee.class, QEmployee.employee.getMetadata());
    Querydsl querydsl = new Querydsl(entityManager, builder);

    JPQLQuery countQuery = createQuery(predicate);
    JPQLQuery query = querydsl.applyPagination(pageable, createQuery(predicate));

    Path<Employee> path = QEmployee.employee;
    Long total = countQuery.count();

    List<Employee> content = total > pageable.getOffset() ? query.list(path) : Collections.<Employee>emptyList();

    return new PageImpl<>(content, pageable, total);
}
 
Example #7
Source File: QTestDbObject.java    From SimpleFlatMapper with MIT License 4 votes vote down vote up
public QTestDbObject(Path<? extends QTestDbObject> entity) {
    super(entity.getType(), entity.getMetadata(), "PUBLIC", "TEST_DB_OBJECT");
}
 
Example #8
Source File: QContact.java    From maven-framework-project with MIT License 4 votes vote down vote up
@SuppressWarnings("all")
public QContact(Path<? extends QContact> path) {
    super((Class)path.getType(), path.getMetadata(), "null", "contact");
}
 
Example #9
Source File: QAddress.java    From maven-framework-project with MIT License 4 votes vote down vote up
@SuppressWarnings("all")
public QAddress(Path<? extends QAddress> path) {
    super((Class)path.getType(), path.getMetadata(), "null", "address");
}
 
Example #10
Source File: QEmployee.java    From maven-framework-project with MIT License 4 votes vote down vote up
@SuppressWarnings("all")
public QEmployee(Path<? extends QEmployee> path) {
    super((Class)path.getType(), path.getMetadata(), "null", "employee");
}
 
Example #11
Source File: QCustomer.java    From maven-framework-project with MIT License 4 votes vote down vote up
@SuppressWarnings("all")
public QCustomer(Path<? extends QCustomer> path) {
    super((Class)path.getType(), path.getMetadata(), "null", "customer");
}