Skip to content

Instantly share code, notes, and snippets.

@eleumik
Created March 25, 2017 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eleumik/c25665a785c7d089fb3890daf8b4e4c0 to your computer and use it in GitHub Desktop.
Save eleumik/c25665a785c7d089fb3890daf8b4e4c0 to your computer and use it in GitHub Desktop.
HibernateQueryCompatibility
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.Session;
/**
* Abstracts the operations on queries
* for compatibility reasons.
* @author michele vivoda
*
*/
public abstract class HibernateQueryCompatibility
{
/**
* Subclasses only constructor.
*/
protected HibernateQueryCompatibility()
{
//
}
/**
* Creates a {@link Query}. See {@link Session#createQuery(String)}.
* @param session a {@link Session}, never <code>null</code>.
* @param hql required HQL
* @return a {@link Query}, never <code>null</code>.
*/
public abstract Query createQuery(Session session, String hql);
/**
* Creates a {@link SQLQuery}. See {@link Session#createSQLQuery(String)}.
* @param session a {@link Session}, never <code>null</code>.
* @param sql required SQL
* @return a {@link SQLQuery}, never <code>null</code>.
*/
public abstract SQLQuery createSQLQuery(Session session, String sql);
/**
* Creates a named {@link Query}. See {@link Session#getNamedQuery(String)}
* @param session a {@link Session}, never <code>null</code>.
* @param name required name
* @return a {@link Query}, never <code>null</code>.
*/
public abstract Query getNamedQuery(Session session, String name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment