DataJPA/src/main/kotlin/com/chantha/jdbc/jpa/repo/ProductRepo.kt
2020-05-17 13:35:32 +07:00

17 lines
594 B
Kotlin

package com.chantha.jdbc.jpa.repo
import com.chantha.jdbc.jpa.model.Product
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository
@Repository
interface ProductRepo : CrudRepository<Product,Long>{
@Query("SELECT * FROM product INNER JOIN order_detail ON (product.product_id=order_detail.product_id)"
, nativeQuery = true)
override fun findAll(): MutableIterable<Product>
@Query("SELECT * FROM product",nativeQuery = true)
fun readAllRecord():List<Product>
}