Reputation: 171
Hello I would like create a method to execute the follow query
SELECT * FROM Customer where customer.customerpremium=true;
I tired implement this method but not working.
public interface CustomerRepository extends CrudRepository<Customer, String>{
Iterable<Customer> findByCustomerPremium(boolean customerpremium);
}
follow my Entity
@Entity
@Table(name = "customer")
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "customerid")
private Integer customerid;
@NotEmpty
@Column(name = "customername")
private String customername;
@NotEmpty
@Column(name = "customeremail")
private String customeremail;
@Column(name = "customerpremium")
private boolean customerpremium;
/**gets and sets*/
}
Upvotes: 1
Views: 2070
Reputation: 15490
your property is in small case customerpremium
try
Iterable<Customer> findByCustomerpremium(boolean customerpremium);
currently this method
Iterable<Customer> findByCustomerPremium(boolean customerpremium);
creating query like this
SELECT * FROM Customer where customer.customer_premium=:customerpremium;
also you can log your sql queries by adding below line in application.properties
file
spring.jpa.show-sql=true
Upvotes: 1