本文整理汇总了Java中org.hibernate.Filter.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Java Filter.setParameter方法的具体用法?Java Filter.setParameter怎么用?Java Filter.setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.Filter
的用法示例。
在下文中一共展示了Filter.setParameter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureHibernateGlobalFilter
import org.hibernate.Filter; //导入方法依赖的package包/类
private void configureHibernateGlobalFilter(Filter filter) {
String filterLanguage = null;
if (getLocale() != null) {
filterLanguage = getLocale().getLanguage();
}
if (filterLanguage == null) {
filterLanguage = "";
}
String filterLogin = null;
if (getApplicationSession().getPrincipal() != null) {
filterLogin = getApplicationSession().getUsername();
}
if (filterLogin == null) {
filterLogin = "";
}
filter.setParameter(JSPRESSO_SESSION_GLOBALS_LANGUAGE, filterLanguage);
filter.setParameter(JSPRESSO_SESSION_GLOBALS_LOGIN, filterLogin);
}
示例2: doBefore
import org.hibernate.Filter; //导入方法依赖的package包/类
public void doBefore(final JoinPoint joinPoint,
final EntityFilter annotation) {
Filter f = sessionFactory.getCurrentSession().enableFilter(
annotation.filter());
String expression;
Integer paramNumber;
Expression exp;
Object subject;
Object[] params = joinPoint.getArgs();
for (FilterAttribute attribute : annotation.params()) {
if (ELParser.isMethodParamExpression(attribute.path())) {
paramNumber = ELParser.getParamNumber(attribute.path());
expression = ELParser.removeParamNumber(attribute.path());
exp = parser.parseExpression(expression);
subject = params[paramNumber];
} else {
exp = parser.parseExpression(attribute.path());
subject = joinPoint.getTarget();
}
f.setParameter(attribute.name(), exp.getValue(subject));
}
}
示例3: enableFilter
import org.hibernate.Filter; //导入方法依赖的package包/类
public void enableFilter(Session session) {
Client client = (Client) sessionObjectsService.getSessionObject(ClientContextObjectContributor.CONTEXT_OBJECT_CLIENT_NAME);
if (client != null) {
LOG.debug("New session created, enabling filter for client selection");
Filter filter = session.enableFilter(CLIENT_FILTER_NAME);
filter.setParameter("client", client.getId());
List<String> organizationList = new ArrayList<String>();
for (Organization org : ((Client) session.get(Client.class, client.getId())).getOrganizations()) {
organizationList.add(org.getId());
}
filter = session.enableFilter(CLIENT_ORGANIZATION_FILTER_NAME);
if (organizationList.size() == 0) {
organizationList.add("NULL_EXPECT_NEVER_HAS_THIS_KEY_BECAUSE_THE_STRING_HAS_MORE_LEN THAN THE PERMITTED_KEY");
}
filter.setParameterList("organizationList", organizationList);
} else {
LOG.debug("Client filter not enabling because client is not established");
}
}
示例4: switchFilter
import org.hibernate.Filter; //导入方法依赖的package包/类
private boolean switchFilter(String filter, CfFlowState flowType, Date startDate, Date endDate, Class clazz, Session session) {
log.debug("filter:" + filter);
log.debug("clazz:" + clazz);
Filter hqlFilter;
try {
if (filter == null) filter = "";
if (null == flowType) {
hqlFilter = session.enableFilter("filter3_" + clazz.getSimpleName());
hqlFilter.setParameter("filter", "%" + filter + "%");
hqlFilter.setParameter("startDate", startDate);
hqlFilter.setParameter("endDate", endDate);
} else {
hqlFilter = session.enableFilter("filter4_" + clazz.getSimpleName());
hqlFilter.setParameter("filter", "%" + filter + "%");
hqlFilter.setParameter("flowState", flowType.ordinal());
hqlFilter.setParameter("startDate", startDate);
hqlFilter.setParameter("endDate", endDate);
}
} catch (Exception e) {
e.printStackTrace();
return true;
}
return false;
}
示例5: applyFilter
import org.hibernate.Filter; //导入方法依赖的package包/类
public void applyFilter(Session session) {
for (int i = 0; i < filterNames.size(); i++) {
Filter filter = session.enableFilter(filterNames.get(i));
HashMap<String, Object> params = filterParams.get(i);
for (Entry<String, Object> filterParam : params.entrySet()) {
filter.setParameter(filterParam.getKey(), filterParam.getValue());
}
}
}
示例6: mainCardsAnnotated
import org.hibernate.Filter; //导入方法依赖的package包/类
public static void mainCardsAnnotated() {
//HibernateUtil.setupDatabase();
primeDatabase();
AnnotationConfiguration configuration = new AnnotationConfiguration();
SessionFactory factory = configuration.configure("test/gov/nih/nci/security/instancelevel/domainobjects/annotated.hibernate.cfg.xml").buildSessionFactory();
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
Map fds= configuration.getFilterDefinitions();
//Show all users
System.out.println("ALL CARDS");
displayCards(session);
//Show Cards with Suit Name = Heart
Filter filter = session.enableFilter("cardName");
filter.setParameter("cardName","Ace");
System.out.println("Annotated: Cards with cardName = Ace");
displayCards(session);
/* //Show activated users
Filter filter = session.enableFilter("activatedFilter");
filter.setParameter("activatedParam",new Boolean(true));
System.out.println("ACTIVATED USERS");
displayUsers(session);
//Show non-activated users
filter.setParameter("activatedParam",new Boolean(false));
System.out.println("NON-ACTIVATED USERS");
displayUsers(session);
*/
session.close();
HibernateUtil.closeDatabaseConnection();
//HibernateUtil.checkData("select * from User");
}
示例7: mainCardsNonAnnotated
import org.hibernate.Filter; //导入方法依赖的package包/类
public static void mainCardsNonAnnotated() {
HibernateUtil.setupDatabase();
primeDatabase();
Configuration c = new Configuration();
SessionFactory factory = c.configure("test/gov/nih/nci/security/instancelevel/domainobjects/nonannotated.hibernate.cfg.xml").buildSessionFactory();
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
//Show all users
System.out.println("ALL CARDS");
displayCards(session);
//Show Cards with Suit Name = Heart
/* Filter filter = session.enableFilter("cardName");
filter.setParameter("cardName","Ace");*/
Filter filter2 = session.enableFilter("imageName");
filter2.setParameter("imageName","Ace1");
System.out.println("Non Annotated: Cards with imageName = Ace1");
displayCards(session);
/* //Show activated users
Filter filter = session.enableFilter("activatedFilter");
filter.setParameter("activatedParam",new Boolean(true));
System.out.println("ACTIVATED USERS");
displayUsers(session);
//Show non-activated users
filter.setParameter("activatedParam",new Boolean(false));
System.out.println("NON-ACTIVATED USERS");
displayUsers(session);
*/
session.close();
HibernateUtil.closeDatabaseConnection();
//HibernateUtil.checkData("select * from User");
}
示例8: mainUsers
import org.hibernate.Filter; //导入方法依赖的package包/类
public static void mainUsers() {
//HibernateUtil.setupDatabase();
//primeDatabase();
//insert the users
insertUser("a",true);/*
insertUser("b",true);
insertUser("c",false);
insertUser("e",false);
insertUser("e",false);*/
AnnotationConfiguration configuration = new AnnotationConfiguration();
SessionFactory factory = configuration.configure().buildSessionFactory();
Session session = factory.openSession();
Transaction tx = session.beginTransaction();
//Show all users
System.out.println("ALL USERS");
displayUsers(session);
//Show activated users
Map fds= configuration.getFilterDefinitions();
Filter filter = session.enableFilter("activatedFilter");
filter.setParameter("activatedParam",new Boolean(true));
System.out.println("ACTIVATED USERS");
displayUsers(session);
//Show non-activated users
filter.setParameter("activatedParam",new Boolean(false));
System.out.println("NON-ACTIVATED USERS");
displayUsers(session);
session.close();
//HibernateUtil.checkData("select * from User");
}
示例9: applyVisibleFilter
import org.hibernate.Filter; //导入方法依赖的package包/类
/**
* Applies the <em>visible</em> filter in the Hibernate session.
*
* @param user
* The user which id is used in <em>visible</em> filter.
* @param session
* The entity manager inner session.
* @see EntityFilters#USER_VISIBLE
* @see EntityFilters#CURRENT_USER_ID
*/
private static void applyVisibleFilter(final User user, final org.hibernate.Session session) {
// Hide entities that this user does not have permission to view.
final Filter filter = session.enableFilter(EntityFilters.USER_VISIBLE);
final int currentUserid = user.getId() == null ? -1 : user.getId(); // Cannot be null.
filter.setParameter(EntityFilters.CURRENT_USER_ID, currentUserid);
}