Skip to content

Commit 09a4248

Browse files
committed
Merge branch 'beta' of https://github.com/OneLiteFeatherNET/vulpes-model into beta
2 parents 6aa1cef + 72cd2db commit 09a4248

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/main/java/net/onelitefeather/vulpes/api/model/sound/SoundFileSource.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import jakarta.persistence.GeneratedValue;
55
import jakarta.persistence.GenerationType;
66
import jakarta.persistence.Id;
7+
import jakarta.persistence.JoinColumn;
8+
import jakarta.persistence.ManyToOne;
79
import net.onelitefeather.vulpes.api.generator.VulpesGenerator;
810
import net.onelitefeather.vulpes.api.model.VulpesModel;
911
import org.hibernate.annotations.ColumnDefault;
@@ -41,6 +43,10 @@ public class SoundFileSource implements VulpesModel {
4143
@ColumnDefault("'type_file'")
4244
private String type;
4345

46+
@ManyToOne
47+
@JoinColumn(name = "sound_event_id")
48+
private SoundEventEntity soundEvent;
49+
4450
/**
4551
* Default constructor for JPA and Micronaut Data.
4652
* <p>
@@ -232,6 +238,14 @@ public boolean isStreamable() {
232238
return stream;
233239
}
234240

241+
public SoundEventEntity getSoundEvent() {
242+
return soundEvent;
243+
}
244+
245+
public void setSoundEvent(SoundEventEntity soundEvent) {
246+
this.soundEvent = soundEvent;
247+
}
248+
235249
@Override
236250
public boolean equals(Object o) {
237251
if (o == null || getClass() != o.getClass()) return false;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.onelitefeather.vulpes.api.repository;
2+
3+
import io.micronaut.data.annotation.Query;
4+
import io.micronaut.data.annotation.Repository;
5+
import io.micronaut.data.model.Page;
6+
import io.micronaut.data.model.Pageable;
7+
import io.micronaut.data.repository.PageableRepository;
8+
import net.onelitefeather.vulpes.api.model.sound.SoundFileSource;
9+
10+
import java.util.List;
11+
import java.util.UUID;
12+
13+
/**
14+
* The {@link SoundFileSourceRepository} interface inherits from {@link PageableRepository} and provides methods to manage {@link SoundFileSource} objects.
15+
*
16+
* @author theEvilReaper
17+
* @version 1.0.0
18+
* @since 1.5.1
19+
*/
20+
@Repository
21+
public interface SoundFileSourceRepository extends PageableRepository<SoundFileSource, UUID> {
22+
23+
/**
24+
* Retrieves the sound file sources associated with a sound event by its ID.
25+
*
26+
* @param id the unique identifier of the sound event
27+
* @param pageable the pagination information
28+
* @return a list of sound file sources associated with the sound event
29+
*/
30+
@Query(value = "SELECT f FROM sound_data f WHERE f.soundEvent.id = :id",
31+
countQuery = "SELECT count(f) FROM sound_data f WHERE f.soundEvent.id = :id")
32+
Page<SoundFileSource> findSoundFileSourcesBySoundEvent(UUID id, Pageable pageable);
33+
34+
}

0 commit comments

Comments
 (0)