Question: I have a spring project. The following first one is my @Repository class, and the second one is my @Service class. The third one is

I have a spring project. The following first one is my @Repository class, and the second one is my @Service class. The third one is the class I define data in database. The question is, I have extends QuerydslPredicateExecutor in repository class, so I can use findAll() with predicate in it, now, how can I create a predicate in the @Service class. Because I'm using repository.findAll() in @Service class so I need to obtain predicates in it. I know there is JPA criteria api that can build predicate, but it's not clear online, can someone give me an example, it doesn't have to be criteria api.

@Repository

public interface InventoryRepository extends MongoRepository, QuerydslPredicateExecutor {

}

@Service

public class InventoryService {

@Autowired

private InventoryRepository InventoryRepository;

}

@Document()

public class InventoryTable {

@Id

String id;

String pid;

String serial_number;

String device_type;

String org_id;

String site_id;

String building_id;

String floor_id;

FloorPosition floor_position;

String model;

String mac;

String firmware_version;

Date claimed_on;

String claimed_by;

List tags;

public InventoryTable() {

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!