All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.v4.servicersv4.ftl Maven / Gradle / Ivy

There is a newer version: 3.0.3
Show newest version
package ${packageName}.service.rs;

import ${groupId}.api.service.RsRepositoryServiceV4;
import ${packageName}.model.${className};

import jakarta.inject.Singleton;
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.Expression;
import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.List;

<#if rsPathIsAppConstant>
import static ${packageName}.management.AppConstants.${rsPath};

@Path(${rsPath})
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Singleton
public class ${className}ServiceRs extends RsRepositoryServiceV4<${className}, ${idFieldType}> {


    public ${className}ServiceRs() {
        super(${className}.class);
    }

    @Override
    protected ${idFieldType} getId(${className} object) {
      // field with @id
      return object.${idFieldName};
    }

    @Override
    protected String getDefaultOrderBy() {
        <#if defaultSort??>
        return "${defaultSort}";
        <#else>
        return "not_set";
        
    }


    @Override
    public Predicate[] query(CriteriaBuilder criteriaBuilder, Root<${className}> root) throws Exception {
        var predicates = new ArrayList();
        return predicates.toArray(new Predicate[]{});
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy