rb.templates.query_builder_impl.erb Maven / Gradle / Ivy
<%= autogenerated %>
package <%= root_package %>.query;
import java.util.Collection;
import <%= JACK_NAMESPACE %>.queries.AbstractQueryBuilder;
import <%= JACK_NAMESPACE %>.queries.Column;
import <%= JACK_NAMESPACE %>.queries.FieldSelector;
import <%= JACK_NAMESPACE %>.queries.where_operators.IWhereOperator;
import <%= JACK_NAMESPACE %>.queries.where_operators.JackMatchers;
import <%= JACK_NAMESPACE %>.queries.WhereConstraint;
import <%= JACK_NAMESPACE %>.queries.QueryOrder;
import <%= JACK_NAMESPACE %>.queries.OrderCriterion;
import <%= JACK_NAMESPACE %>.queries.LimitCriterion;
import <%= root_package %>.iface.<%= model_defn.iface_name %>;
import <%= root_package %>.models.<%= model_defn.model_name %>;
public class <%= model_defn.query_builder_name %> extends AbstractQueryBuilder<<%=model_defn.model_name%>> {
public <%= model_defn.query_builder_name %>(<%= model_defn.iface_name %> caller) {
super(caller);
}
public <%= model_defn.query_builder_name %> select(<%=model_defn.model_name %>._Fields... fields) {
for (<%=model_defn.model_name %>._Fields field : fields){
addSelectedField(new FieldSelector(field));
}
return this;
}
public <%= model_defn.query_builder_name %> selectAgg(FieldSelector... aggregatedFields) {
addSelectedFields(aggregatedFields);
return this;
}
public <%= model_defn.query_builder_name %> id(Long value) {
addId(value);
return this;
}
public <%= model_defn.query_builder_name %> idIn(Collection values) {
addIds(values);
return this;
}
public <%= model_defn.query_builder_name %> whereId(IWhereOperator operator) {
addWhereConstraint(new WhereConstraint<>(Column.fromId(null), operator, null));
return this;
}
public <%= model_defn.query_builder_name %> limit(int offset, int nResults) {
setLimit(new LimitCriterion(offset, nResults));
return this;
}
public <%= model_defn.query_builder_name %> limit(int nResults) {
setLimit(new LimitCriterion(nResults));
return this;
}
public <%= model_defn.query_builder_name %> groupBy(<%=model_defn.model_name %>._Fields... fields) {
addGroupByFields(fields);
return this;
}
public <%= model_defn.query_builder_name %> order() {
this.addOrder(new OrderCriterion(QueryOrder.ASC));
return this;
}
public <%= model_defn.query_builder_name %> order(QueryOrder queryOrder) {
this.addOrder(new OrderCriterion(queryOrder));
return this;
}
public <%= model_defn.query_builder_name %> orderById() {
this.addOrder(new OrderCriterion(QueryOrder.ASC));
return this;
}
public <%= model_defn.query_builder_name %> orderById(QueryOrder queryOrder) {
this.addOrder(new OrderCriterion(queryOrder));
return this;
}
<% model_defn.fields.each do |field_defn| %>
public <%= model_defn.query_builder_name %> <%= field_defn.name.camelcase(:lower) %>(<%= field_defn.java_type(true) %> value) {
addWhereConstraint(new WhereConstraint<>(<%= model_defn.model_name %>._Fields.<%= field_defn.name %>, JackMatchers.equalTo(value)));
return this;
}
public <%= model_defn.query_builder_name %> where<%= field_defn.name.camelcase() %>(IWhereOperator<<%= field_defn.java_type(true) %>> operator) {
addWhereConstraint(new WhereConstraint<>(<%= model_defn.model_name %>._Fields.<%= field_defn.name %>, operator));
return this;
}
public <%= model_defn.query_builder_name %> orderBy<%= field_defn.name.camelcase() %>() {
this.addOrder(new OrderCriterion(<%= model_defn.model_name %>._Fields.<%= field_defn.name %>, QueryOrder.ASC));
return this;
}
public <%= model_defn.query_builder_name %> orderBy<%= field_defn.name.camelcase() %>(QueryOrder queryOrder) {
this.addOrder(new OrderCriterion(<%= model_defn.model_name %>._Fields.<%= field_defn.name %>, queryOrder));
return this;
}
<% end %>
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy