Marcio Jota Coelho
Marcio Jota Coelho

Reputation: 11

Change default panache filters

I use Quarkus 3.15 with PostgreSQL and Panache extension. My small application needs different filters by data type. For example, string type fields, I need the SQL query generated by Panache to be made with the LIKE clause, and for numeric fields to be possible for me to add > or < to perform the filter How can I intercept the standard query and change this standard filter to a more complete one?

This is my Entity exemple:

@Entity
@Table(name = "application")
public class Application extends PanacheEntityBase {

    @Transient
    @JsonIgnore
    public static final String ADMIN_APP = "admin";

    @Column(unique = true)
    public String app_internal_id;
    
    public String app_description;

    public Float app_value;

    @Transient
    public Integer user_id;

}

and this, my Resteasy resource exemple:

@ResourceProperties(rolesAllowed = { "${admin-role}" })
public interface CrudApplicationResource extends PanacheEntityResource<Application, Integer> {

    public static final String RESOURCE_PATH = "crud-application";
}

Is it possible to add a flag to change the type of filter used in standard panache queries?

I need possible to replicate to all entities of project

Upvotes: 0

Views: 24

Answers (0)

Related Questions