Skip to content

Instantly share code, notes, and snippets.

View jcalvert's full-sized avatar

Jonathan Calvert jcalvert

View GitHub Profile
@jcalvert
jcalvert / HqlLexer.patch
Created April 28, 2011 14:43
Hibernate HqlLexer patch.
--- hibernate-core/src/main/java/org/hibernate/hql/ast/HqlLexer.java 2011-04-28 10:39:48.000000000 -0400
+++ hibernate-core/src/main/java/org/hibernate/hql/ast/HqlLexer.java 2011-04-28 10:40:56.000000000 -0400
@@ -51,7 +51,7 @@
public void setTokenObjectClass(String cl) {
// Ignore the token class name parameter, and use a specific token class.
- super.setTokenObjectClass( HqlToken.class.getName() );
+ tokenObjectClass = HqlToken.class;
}
@jcalvert
jcalvert / gist:922038
Created April 15, 2011 17:01
Is there a better way?
class Array
def to_hash(&block)
Hash[*self.collect { |v|
block.call(v).flatten
}.flatten]
end
end
# so that ["foobar", "barfoo"].to_hash{|i| [i.upcase, i.downcase] }
# yields {"FOOBAR"=>"foobar", "BARFOO"=>"barfoo"}
@jcalvert
jcalvert / gist:920637
Created April 14, 2011 21:46
Ugh. Doing so little with so much.
public final static String PERCENTAGE_TAGS = "%%";
public final static String OPEN_FLOWER_BRACKET = "{";
public final static String CLOSE_FLOWER_BRACKET = "}";
private static String replaceFlowerBrackets(String strQry) throws Exception {
strQry = strQry.replaceAll(Pattern.quote(OPEN_FLOWER_BRACKET), PERCENTAGE_TAGS);
strQry = strQry.replaceAll(Pattern.quote(CLOSE_FLOWER_BRACKET), PERCENTAGE_TAGS);
return strQry;
}