63 |
return result; |
return result; |
64 |
} |
} |
65 |
|
|
66 |
|
/* |
67 |
|
* this code requires theses statements are run on database in order to do ILIKE searches against aliases (which is defines as array of varchar(64) ) |
68 |
|
* create function rlike(text,text) returns bool as |
69 |
|
* 'select $2 ilike $1' language sql strict immutable; |
70 |
|
* create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~); |
71 |
|
*/ |
72 |
public List<StationBean> getByName(String name) throws SQLException { |
public List<StationBean> getByName(String name) throws SQLException { |
73 |
String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " + |
String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " + |
74 |
"FROM trainstations " + |
"FROM trainstations " + |
75 |
"WHERE name ILIKE ? AND enabled = true " + |
"WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " + |
76 |
"ORDER BY name "; |
"ORDER BY name "; |
77 |
|
|
78 |
|
|
85 |
stmt = conn.prepareStatement(SQL); |
stmt = conn.prepareStatement(SQL); |
86 |
|
|
87 |
stmt.setString(1, name + "%"); |
stmt.setString(1, name + "%"); |
88 |
|
stmt.setString(2, name + "%"); |
89 |
|
|
90 |
res = stmt.executeQuery(); |
res = stmt.executeQuery(); |
91 |
result = convertResultset(res); |
result = convertResultset(res); |