-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Keith Donald opened SPR-9228 and commented
It's much easier to maintain non-trivial SQL like the example below(1) when it is externalized into a separate file. It wouldn't take much to provide basic support in Spring JDBC for loading SQL from externalized resources. I don't want to bring in another tool like MyBatis just for this. I rolled my own implementation based on some code from ResourceDatabasePopulator(2).
(1)
SELECT o.id as organization_id, o.name as organization_name, o.logo as organization_logo, u.username as organization_username,
l.id as league_id, l.slug as league_slug, l.sport as league_sport, l.format as league_format, l.nature as league_nature,
s.number as season_number, s.name as season_name, s.picture as season_picture, s.start_date as season_start_date,
v.venue_id, v.venue_name, v.venue_latitude, v.venue_longitude
FROM seasons s
INNER JOIN leagues l ON s.league = l.id
INNER JOIN organizations o ON l.organization = o.id
INNER JOIN (SELECT l.league, l.venue as venue_id, v.name as venue_name, v.latitude as venue_latitude, v.longitude as venue_longitude
FROM league_venues l
INNER JOIN venues v ON l.venue = v.id
WHERE l.primary_venue = true) v ON l.id = v.league
LEFT OUTER JOIN usernames u ON o.id = u.organization
WHERE s.status = 'o'
(2) https://gist.github.com/2018152
Affects: 3.1.1
Reference URL: http://stackoverflow.com/a/835323
Issue Links:
- Improve comment handling in ResourceDatabasePopulator [SPR-9261] #13899 Improve comment handling in ResourceDatabasePopulator
1 votes, 3 watchers
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement