Announcement Announcement Module
Collapse
No announcement yet.
@DBref + QueryDslPredicateExecutor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @DBref + QueryDslPredicateExecutor

    Sources:
    GadgetRepository
    Code:
    @Repository(value = "gadgetRepository")
    public interface GadgetRepository extends CrudRepository<Gadget, String>, QueryDslPredicateExecutor<Gadget> {
    }
    Gadget
    Code:
    @XmlRootElement
    @Document(collection="gadget")
    @PersistenceCapable
    public class Gadget {
        @Id
        private String id;
    
        private String url;
    
        private Long timestamp;
    
        @DBRef(collection="status")
        private Status status;
    GadgetService
    Code:
    QGadget gadget = QGadget.gadget;
            
            BooleanBuilder expressionBuilder = new BooleanBuilder();
            if (StringUtils.hasText(status)) {
                expressionBuilder.and(gadget.status.name.equalsIgnoreCase(status));
            }
    
            return (List<Gadget>) gadgetRepository.findAll(expressionBuilder);
    Code:
    gadgetService.getGadgets("APPROVED");
    returns 0.

    What is my mistake?
Working...
X