List of usage examples for org.hibernate.persister.collection CollectionPropertyNames COLLECTION_ELEMENTS
String COLLECTION_ELEMENTS
To view the source code for org.hibernate.persister.collection CollectionPropertyNames COLLECTION_ELEMENTS.
Click Source Link
From source file:com.eucalyptus.auth.DatabaseAuthProvider.java
License:Open Source License
public User lookupUserByEmailAddress(String email) throws AuthException { if (email == null || "".equals(email)) { throw new AuthException("Empty email address to search"); }//from w w w . ja v a2 s . c o m final EntityTransaction tx = Entities.get(UserEntity.class); try { final UserEntity match = (UserEntity) Entities.createCriteria(UserEntity.class).setCacheable(true) .createAlias("info", "i") .add(Restrictions.eq("i." + CollectionPropertyNames.COLLECTION_ELEMENTS, email).ignoreCase()) .setFetchMode("info", FetchMode.JOIN).setReadOnly(true).uniqueResult(); if (match == null) { throw new AuthException(AuthException.NO_SUCH_USER); } boolean emailMatched = false; Map<String, String> info = match.getInfo(); if (info != null) { for (Map.Entry<String, String> entry : info.entrySet()) { if (entry.getKey() != null && User.EMAIL.equals(entry.getKey()) && entry.getValue() != null && email.equalsIgnoreCase(entry.getValue())) { emailMatched = true; break; } } } if (!emailMatched) { throw new AuthException(AuthException.NO_SUCH_USER); } return new DatabaseUserProxy(match); } catch (AuthException e) { Debugging.logError(LOG, e, "Failed to find user by email address " + email); throw e; } catch (Exception e) { Debugging.logError(LOG, e, "Failed to find user by email address " + email); throw new AuthException(AuthException.NO_SUCH_USER, e); } finally { tx.rollback(); } }
From source file:com.eucalyptus.auth.euare.persist.DatabaseAuthProvider.java
License:Open Source License
public EuareUser lookupUserByEmailAddress(String email) throws AuthException { if (email == null || "".equals(email)) { throw new AuthException("Empty email address to search"); }//w w w. java 2 s.c om final EntityTransaction tx = Entities.get(UserEntity.class); try { final UserEntity match = (UserEntity) Entities.createCriteria(UserEntity.class).setCacheable(true) .createAlias("info", "i") .add(Restrictions.eq("i." + CollectionPropertyNames.COLLECTION_ELEMENTS, email).ignoreCase()) .setFetchMode("info", FetchMode.JOIN).setReadOnly(true).uniqueResult(); if (match == null) { throw new AuthException(AuthException.NO_SUCH_USER); } boolean emailMatched = false; Map<String, String> info = match.getInfo(); if (info != null) { for (Map.Entry<String, String> entry : info.entrySet()) { if (entry.getKey() != null && User.EMAIL.equals(entry.getKey()) && entry.getValue() != null && email.equalsIgnoreCase(entry.getValue())) { emailMatched = true; break; } } } if (!emailMatched) { throw new AuthException(AuthException.NO_SUCH_USER); } return new DatabaseUserProxy(match); } catch (AuthException e) { Debugging.logError(LOG, e, "Failed to find user by email address " + email); throw e; } catch (Exception e) { Debugging.logError(LOG, e, "Failed to find user by email address " + email); throw new AuthException(AuthException.NO_SUCH_USER, e); } finally { tx.rollback(); } }
From source file:cz.jirutka.rsql.visitor.hibernate.HibernateCriterionVisitor.java
License:Apache License
private Type getPropertyType(BasicType basicType, String property) { if (CollectionPropertyNames.COLLECTION_ELEMENTS.equals(property)) { return basicType; } else if (CollectionPropertyNames.COLLECTION_INDEX.equals(property)) { return IntegerType.INSTANCE; }/*from www .j a v a2 s. c o m*/ throw new IllegalArgumentException("Not handled: " + basicType + " with property: " + property); }