Regular Expressions 101

Community Patterns

1...34567...283

Hibernate SQL Reductor

4

Regular Expression
ECMAScript (JavaScript)

/
((\w+)\.(\w+) as \3(\d_\d)_)(, \2\.\w+ as \w+)*
/
g

Description

If you want to understand an SQL statement for Hibernate: this replaces the selected fields in an SQL statement generated by Hibernate by a shorthand, since you usually just care about the logic. E.g. it changes select foo0_.bla as bla1_3, foo0_.bar as bar1_3, foo0_.baz1_3 as baz1_3 from ... to select foo0_.**1_3 from ...

Submitted by Hans-Peter Stoerr www.stoerr.net - 9 years ago