Home > Back-end >  Spring jpa dynamic SQL query, can't get to the enum attributes in the entity class
Spring jpa dynamic SQL query, can't get to the enum attributes in the entity class

Time:01-28

1, entity class
Public class RechargeApply extends Domain {

Private static final long serialVersionUID=1785331450982369268 l;

Private RechargeStatusEnum status;

2, the query assembled:
Predicate Predicate=builder. Conjunction (); Dynamic SQL expression//
List ExpressionList=predicate. GetExpressions ();
If (dto. GetStartTime ()!=null & amp; & Dtos. GetEndTime ()!=null) {
ExpressionList. Add (builder. Between (root) get (" createDate "), a dto. GetStartTime (), dto. GetEndTime ()));
}
If (StringUtils. IsNotEmpty (dto. GetRechargeType ())) {
ExpressionList. Add (builder. Equal (root) get (" rechargeType "),
RechargeTypeEnum. StringOf (dto. GetRechargeType ())));
}
If (StringUtils. IsNotEmpty (dto. GetStatus ())) {
ExpressionList. Add (builder. Equal (root) get (" status "), RechargeStatusEnum. StringOf (dto) getStatus ())));
}

Error:
Java. Lang. IllegalArgumentException: Unable to locate the Attribute with the the given name [status] on this ManagedType

What a great god, please help to see what's going on?

CodePudding user response:

Has been resolved
ExpressionList. Add (builder. Equal (root. & lt; String> Get (" rechargeType "), RechargeTypeEnum stringOf (dto) getRechargeType ())));
  • Related