Package de.tsl2.nano.persistence
Class SQLQuery
java.lang.Object
de.tsl2.nano.persistence.SQLQuery
public class SQLQuery
extends Object
implements de.tsl2.nano.core.execution.IRunnable<Object,String>
provides some convenience for a persistence with an entitymanager with native queries
and executions. In a JTA context you have to give a sessioncontext.
NOTE: method
get(Class, String, Object...) works not with native
query! Use select(String, Object...) instead.- Author:
- Thomas Schneider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()javax.ejb.SessionContextcreateSessionContextProxyForTest(ClassLoader classLoader) javax.persistence.EntityManagerem()int<T> List<T>intintstatic <T> T<T> javax.persistence.QueryvoidList<?>javax.persistence.QuerywithParameters(javax.persistence.Query query, Object... args) <T> TwithTransaction(Supplier<T> s)
-
Constructor Details
-
SQLQuery
-
SQLQuery
public SQLQuery(javax.persistence.EntityManager em, javax.ejb.SessionContext sessionContext) in a container with JTA context you have to give the @Resource SessionContext to get the UserTransaction -
SQLQuery
public SQLQuery(javax.persistence.EntityManager em)
-
-
Method Details
-
em
public javax.persistence.EntityManager em() -
close
public void close() -
execute
-
select
-
query
-
get
-
getCount
-
getInt
-
withParameters
-
rollbackIfActive
public void rollbackIfActive() -
createSessionContextProxyForTest
-
withTransaction
-
print
-
run
-