Skip to content

Instantly share code, notes, and snippets.

@alex-ber
Created September 25, 2021 17:38
Show Gist options
  • Select an option

  • Save alex-ber/f0076eb50d2291f95c4bdcb7b4067bf7 to your computer and use it in GitHub Desktop.

Select an option

Save alex-ber/f0076eb50d2291f95c4bdcb7b4067bf7 to your computer and use it in GitHub Desktop.
package jcg.zheng.demo.jpademo.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import jcg.zheng.demo.jpademo.entity.Contact;
import jcg.zheng.demo.jpademo.type.PhoneType;
@Repository
@Transactional
public interface ContactRepository extends JpaRepository<Contact, Long> {
@Query("SELECT con FROM Contact con WHERE con.phoneType=(:pType) AND con.lastName= (:lName)")
List<Contact> findByLastNameAndPhoneType(@Param("pType") PhoneType pType, @Param("lName") String lName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment