-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...main/java/com/emma/curso/springboot/jpa/springboot_jpa/repositories/PersonRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
package com.emma.curso.springboot.jpa.springboot_jpa.repositories; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import com.emma.curso.springboot.jpa.springboot_jpa.entities.Person; | ||
|
||
public interface PersonRepository extends CrudRepository<Person,Long> { | ||
|
||
@Query("select new Person(p.name, p.lastname) from Person p") | ||
List<Person> findAllObjectPersonPersonalized(); | ||
|
||
@Query("select p from Person p where p.id=?1") | ||
String getNameById(Long id); | ||
|
||
@Query("select concat(p.name, ' ', p.lastname) as fullname from Person p where p.id=?1") | ||
String getFullNameById(Long id); | ||
|
||
List<Person> findByProgrammingLanguage(String programmingLanguage); | ||
|
||
Optional<Person> findByNameStartingWithIgnoreCase(String name); | ||
|
||
Optional<Person> findByNameIgnoreCase(String name); | ||
|
||
Optional<Person> findByNameContaining(String name); | ||
|
||
@Query("select p from Person p where p.programmingLanguage=?1") | ||
List<Person> buscarByProgrammingLanguague(String programmingLanguague); | ||
|
||
List<Person> findByProgrammingLanguageAndName(String programmingLanguage, String name); | ||
|
||
@Query("select p.name, p.programmingLanguage from Person p") | ||
List<Object[]> obtenerPersonData(); | ||
|
||
@Query("select p.name, p.programmingLanguage from Person p where p.programmingLanguage=?1 and p.name=?2") | ||
List<Object[]> obtenerPersonData(String programmingLanguage, String name); | ||
|
||
|
||
} |