I have this table:
@Entity
@Table(name = "t_tropical",
uniqueConstraints =
@UniqueConstraint(columnNames = {
"name",
"sign",
"isRetro",
"house",
"lang"}))
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
public class Tropical {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String sign;
private Boolean isRetro;
private Integer house;
private String lang;
private Date updateDate;
}
and this method:
@Repository
public interface TropicalRepository extends JpaRepository<Tropical, Long> {
Tropical findByHouseIsAndSignAndIsRetroAndLangIs
(Integer house, String sign, Boolean retro, String lang);
}
but does not seems to work. I found for existing house / sign / isRetro and land and return null
2
Answers
The correct query should look as follows using the JPA naming conventions:
In your query there seemed to be an
Is
appended toHouse
and toLang
. These cannot be resolved based on the attributes in your entity.Please make sure you are following spring Data JPA naming conventions as documented here: spring-data-derived-queries.
In your example you seem not to follow those