Skip to content

🎢 Examples from the Rave Scene

Let’s translate some real-world rave scenarios into RaveRepository operations!

Example 1: Fetching Tracks by BPM

Scenario: You’re curating a setlist for a hardcore rave and need tracks with specific BPMs.

@SqlPath("sql/getTracksByBPM.sql")
public List<Track> getTracksByBPM(int bpm) {
return raveRepository.query(Track.class, "bpm", bpm);
}

SQL (getTracksByBPM.sql):

SELECT * FROM tracks WHERE bpm = :bpm;

Example 2: Updating Festival Information

Scenario: A festival updates their profile with new social media handles.

@SqlPath("sql/updateFestivalInfo.sql")
public int updateRaverInfo(FestivalUpdate update) {
return raveRepository.update(update);
}

SQL (updateFestivalInfo.sql):

UPDATE festival
SET twitter = :twitter, instagram = :instagram
WHERE id = :id;

Example 3: Preloading SQL Queries Before the Rave

Scenario: Before the rave starts, preload essential SQL scripts to ensure no delays during the event.

public void prepareRaveNight() {
List<String> sqlTracks = Arrays.asList(
"sql/getAllRavers.sql",
"sql/getAllTracks.sql",
"sql/getAllEvents.sql"
);
raveRepository.preloadSqlQueries(sqlTracks);
}