Skip to content

How to make dynamic query #212

@hongdor

Description

@hongdor

Hi,
I want to make dynamic query

now I am using like this :

        if (search.getSensorId() == null && search.getContainerId() != null) {
            if(search.getClassCode() != null){
                restriction = Restrictions.and(
                        Restrictions.tag("containerId").equal(search.getContainerId()),
                        Restrictions.tag("classCode").equal(search.getClassCode()),
                        Restrictions.measurement().equal("data")
                );
            }else {
                restriction = Restrictions.and(
                        Restrictions.tag("containerId").equal(search.getContainerId()),
                        Restrictions.measurement().equal("data")
                );
            }
        }

is there any better way?


p.s
Whenever I call influx reading method, I close influxDBClient. is it right way?
Our project is going to have a lot of traffic.

@controller
public class Controller{
     public ClassA method(){
         private InfluxDBClient influxDBClient = InfluxDBClientFactory.create(connectionUrl, token.toCharArray(), orgId);
         ...
        
         List<ClassA> results = queryApi.query(flux.toString(), ClassA.class);
         influxConnectService.close();        
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions