public QueryHintDefinition(final QueryHint[] hints) { if ( hints == null || hints.length == 0 ) { hintsMap = Collections.emptyMap(); } else { final Map<String, Object> hintsMap = new HashMap<String, Object>(); for ( QueryHint hint : hints ) { hintsMap.put( hint.name(), hint.value() ); } this.hintsMap = hintsMap; } }
/** * Protected to be able to customize in sub-classes. * * @param query must not be {@literal null}. * @param hint must not be {@literal null}. */ protected <T extends Query> void applyQueryHint(T query, QueryHint hint) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(hint, "QueryHint must not be null!"); query.setHint(hint.name(), hint.value()); }
private static Map<String, Object> findQueryHints(Method method) { Map<String, Object> queryHints = new HashMap<String, Object>(); QueryHints queryHintsAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, QueryHints.class); if (queryHintsAnnotation != null) { for (QueryHint hint : queryHintsAnnotation.value()) { queryHints.put(hint.name(), hint.value()); } } QueryHint queryHintAnnotation = AnnotationUtils.findAnnotation(method, QueryHint.class); if (queryHintAnnotation != null) { queryHints.put(queryHintAnnotation.name(), queryHintAnnotation.value()); } return Collections.unmodifiableMap(queryHints); }
/** * Prepare any {@link QueryHint} declarations * * @param constantPool * @param queryHints * @param hint */ protected void prepareQueryHints(ConstPool constantPool, List<AnnotationMemberValue> queryHints, QueryHint hint) { Annotation queryHint = new Annotation(QueryHint.class.getName(), constantPool); StringMemberValue hintName = new StringMemberValue(constantPool); hintName.setValue(hint.name()); queryHint.addMemberValue("name", hintName); StringMemberValue hintValue = new StringMemberValue(constantPool); hintValue.setValue(hint.value()); queryHint.addMemberValue("value", hintValue); AnnotationMemberValue hintAnnotation = new AnnotationMemberValue(queryHint, constantPool); queryHints.add(hintAnnotation); } }
private static String getString(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { return hint.value(); } } return null; }
private static boolean getBoolean(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { if ( hint.value().equalsIgnoreCase( "true" ) ) { return true; } else if ( hint.value().equalsIgnoreCase( "false" ) ) { return false; } else { throw new AnnotationException( "Not a boolean in hint: " + query + ":" + hint.name() ); } } } return false; }
private static Integer getInteger(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { try { return Integer.decode( hint.value() ); } catch (NumberFormatException nfe) { throw new AnnotationException( "Not an integer in hint: " + query + ":" + hint.name(), nfe ); } } } return null; }
private static CacheMode getCacheMode(String query, QueryHint[] hints) { for (QueryHint hint : hints) { if ( "org.hibernate.cacheMode".equals( hint.name() ) ) { if ( hint.value().equalsIgnoreCase( CacheMode.GET.toString() ) ) { return CacheMode.GET; } else if ( hint.value().equalsIgnoreCase( CacheMode.IGNORE.toString() ) ) { return CacheMode.IGNORE; } else if ( hint.value().equalsIgnoreCase( CacheMode.NORMAL.toString() ) ) { return CacheMode.NORMAL; } else if ( hint.value().equalsIgnoreCase( CacheMode.PUT.toString() ) ) { return CacheMode.PUT; } else if ( hint.value().equalsIgnoreCase( CacheMode.REFRESH.toString() ) ) { return CacheMode.REFRESH; } else { throw new AnnotationException( "Unknown CacheMode in hint: " + query + ":" + hint.name() ); } } } return null; }
private static FlushMode getFlushMode(String query, QueryHint[] hints) { for (QueryHint hint : hints) { if ( "org.hibernate.flushMode".equals( hint.name() ) ) { if ( hint.value().equalsIgnoreCase( FlushMode.ALWAYS.toString() ) ) { return FlushMode.ALWAYS; } else if ( hint.value().equalsIgnoreCase( FlushMode.AUTO.toString() ) ) { return FlushMode.AUTO; } else if ( hint.value().equalsIgnoreCase( FlushMode.COMMIT.toString() ) ) { return FlushMode.COMMIT; } else if ( hint.value().equalsIgnoreCase( FlushMode.NEVER.toString() ) ) { return FlushMode.MANUAL; } else if ( hint.value().equalsIgnoreCase( FlushMode.MANUAL.toString() ) ) { return FlushMode.MANUAL; } else { throw new AnnotationException( "Unknown FlushMode in hint: " + query + ":" + hint.name() ); } } } return null; }
private static String getString(String query, String hintName, QueryHint[] hints) { for ( QueryHint hint : hints ) { if ( hintName.equals( hint.name() ) ) { return hint.value(); } } return null; }
private static String getString(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { return hint.value(); } } return null; }
public QueryHintDefinition(final QueryHint[] hints) { if ( hints == null || hints.length == 0 ) { hintsMap = Collections.emptyMap(); } else { final Map<String, Object> hintsMap = new HashMap<String, Object>(); for ( QueryHint hint : hints ) { hintsMap.put( hint.name(), hint.value() ); } this.hintsMap = hintsMap; } }
private static String getString(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { return hint.value(); } } return null; }
/** * Protected to be able to customize in sub-classes. * * @param query must not be {@literal null}. * @param hint must not be {@literal null}. */ protected <T extends Query> void applyQueryHint(T query, QueryHint hint) { Assert.notNull(query, "Query must not be null!"); Assert.notNull(hint, "QueryHint must not be null!"); query.setHint(hint.name(), hint.value()); }
private static Map<String, Object> findQueryHints(Method method) { Map<String, Object> queryHints = new HashMap<String, Object>(); QueryHints queryHintsAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, QueryHints.class); if (queryHintsAnnotation != null) { for (QueryHint hint : queryHintsAnnotation.value()) { queryHints.put(hint.name(), hint.value()); } } QueryHint queryHintAnnotation = AnnotationUtils.findAnnotation(method, QueryHint.class); if (queryHintAnnotation != null) { queryHints.put(queryHintAnnotation.name(), queryHintAnnotation.value()); } return Collections.unmodifiableMap(queryHints); }
private static Map<String, Object> findQueryHints(Method method) { Map<String, Object> queryHints = new HashMap<String, Object>(); QueryHints queryHintsAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, QueryHints.class); if (queryHintsAnnotation != null) { for (QueryHint hint : queryHintsAnnotation.value()) { queryHints.put(hint.name(), hint.value()); } } QueryHint queryHintAnnotation = AnnotationUtils.findAnnotation(method, QueryHint.class); if (queryHintAnnotation != null) { queryHints.put(queryHintAnnotation.name(), queryHintAnnotation.value()); } return Collections.unmodifiableMap(queryHints); }
private static Integer getInteger(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { try { return Integer.decode( hint.value() ); } catch (NumberFormatException nfe) { throw new AnnotationException( "Not an integer in hint: " + query + ":" + hint.name(), nfe ); } } } return null; }
protected void addHints(QueryMetaData meta, QueryHint...hints) { for (QueryHint hint : hints) meta.addHint(hint.name(), hint.value()); }
protected void addHints(QueryMetaData meta, QueryHint...hints) { for (QueryHint hint : hints) meta.addHint(hint.name(), hint.value()); }
private static Integer getInteger(String query, String hintName, QueryHint[] hints) { for (QueryHint hint : hints) { if ( hintName.equals( hint.name() ) ) { try { return Integer.decode( hint.value() ); } catch (NumberFormatException nfe) { throw new AnnotationException( "Not an integer in hint: " + query + ":" + hint.name(), nfe ); } } } return null; }