I have tried to put a full class path (com.xxxx.State.Finish) after !=
but not helping.
@Query("select c from CustomOrder c where c.dealer = :roleName and
c.nextManager = null and c.currentState != Finish")
List<CustomOrder> findOpenOrder(@Param("roleName") String roleName);
Entity:
@Getter
@Enumerated(EnumType.STRING)
CustomOrderEnums.State currentState;
Enum:
public enum State {
Open, Finish
}
Use Enums as Request Parameters Or we can use it as a PathVariable: @GetMapping("/findbymode/{mode}") public String findByEnum(@PathVariable("mode") Modes mode) { // ... } When we make a web request, such as /mode2str? mode=ALPHA, the request parameter is a String object.
You can use the name() or toString() method of your Enum . You can provide an additional "translation" inside the Enum like: public enum Status { S1("translation1"), S2("translation2"), S3("translation3"); private final String translation; private Status(String t) { translation = t; } ... }
@Query("select c from CustomOrder c where c.dealer = :roleName and
c.nextManager = null and c.currentState != com.xxx.FooEnum.Finish")
FooEnum
has to be a top class not an inner one. If it has to be an inner class, use '
quoted string (haven't tried it without '
).
@Query("select c from CustomOrder c where c.dealer = :roleName and
c.nextManager = null and c.currentState != 'Finish'")
I have just found that instead of using @Query
it could be simply used as:
List<User> findIdByRoleRoleAndProvinceType(String role, ProvinceEnum.ProvinceType provinceType);
and this is entity User:
@Entity
public class User {
Role role; // entity has a String field role;
Province province; // entity has a ProvinceEnum.ProvinceType field type.
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With