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

com.tri.persistence.jpql.Parameter Maven / Gradle / Ivy

Go to download

Create dynamic JPQL queries with a fluent API without cluttering code with String concatenations

The newest version!
package com.tri.persistence.jpql;

import java.util.Date;

import javax.persistence.Query;

/**
 * 

* {@literal JPQL} parameter holder. The query builder holds a list of * parameters and applies them during the build process. There is an * implementation for every parameter type, e.g. {@link Object}, {@link Date} * etc. *

*

* {@code Parameter} objects are (almost) immutable. Passed mutable value * objects changed via kept references break immutableness of {@code Parameter} * objects. *

* * @param * the type of the parameter */ abstract public class Parameter { final protected String name; final protected Integer position; final protected T value; /** * Constructor * * @param name * parameter name * @param value * parameter value, pass an immutable object or pass a copy not * used any further */ public Parameter(final String name, final T value) { this.name = name; this.position = null; this.value = value; } /** * Constructor * * @param position * position * @param value * parameter value, pass an immutable object or pass a copy not * used any further */ public Parameter(final int position, final T value) { this.position = position; this.name = null; this.value = value; } /** * Applies this parameter to given query. */ public abstract void apply(Query query); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy