Entity:
@Getter
@Setter
@NoArgsConstructor
@Entity
@ToString
@DynamicUpdate
@Table(name = "flow_plan_details")
public class FlowPlanDetails extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Existing.class)
@Null(groups = New.class)
private Long flowPlanId;
private Integer itemNbr;
private String itemDescription;
private String season;
private Integer fiscalYear;
private String catDesc;
private String subcatDesc;
private String gmm;
private String dmm;
private String planStatus;
private String channel;
private Boolean isLcl;
private String imageUrl;
private Integer carryOverItemNbr;
private Integer palletQty;
private Integer totalContQty;
private Integer commitmentQty;
private Integer defaultPresentation;
private LocalDate inClubDate;
private LocalDate oosDate;
private String eventCode;
private Integer clubCount;
private Integer percContainerRoundUp;
private String portOfOrigin;
private String productId;
private String flowRounding;
private String breakdownCalculation;
private Integer wos;
private Integer lastWeekToReceive;
private String targetOhRule;
private Float itemCost;
private Float itemRetail;
private Float shippingCostPerPallet;
private Float shippingCostPerContainer;
private Float profitPerItem;
private Float lostSale;
private Float containerShippingCost;
private Float totalCost;
private String holidayName;
private LocalDate holidayStartDate;
private LocalDate holidayEndDate;
private LocalDate holidayDate;
private String applyHoliday;
private Float plannedContainers;
private Float plannedPallets;
private Float flowContainers;
private Float flowPallets;
private Float differenceInContainers;
private Float differenceInPallets;
private LocalDateTime lastGeneratedFlowPlan;
private Long rolloutId;
private Boolean isRolloutRefreshRequired;
private Boolean isArchived = false;
private Float weight;
private Float dimension1;
private Float dimension2;
private Float dimension3;
private Boolean sorted;
private String impactDropdown;
private Boolean isReadyForScgs;
private String finalizedStatus;
public interface Existing {
}
public interface New {
}
public String getFlowplanIdWithName()
{
return this.getFlowPlanId().toString()+" - "+this.getItemDescription()+" - "+ this.getChannel();
}
}
Im running this query:
@Query("""
select f from FlowPlanDetails f
where f.last_updated_on between :startDate and :endDate
and f.plan_status=:planStatus and f.is_archived=:isArchived
and f.cat_desc= :catDesc
""") //(:catDesc is NULL OR f.cat_desc= :catDesc)
Page<FlowPlanDetails> customSpotQuery(@Param("catDesc") String catDesc,
@Param("startDate") ZonedDateTime startDate,
@Param("endDate") ZonedDateTime endDate,
@Param("planStatus") String planStatus,
@Param("isArchived") Boolean isArchived, Pageable page);
Im getting this error:
Caused by: java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: last_updated_on of: com.walmart.sams.services.allocation.configuration.service.model.FlowPlanDetails [select f from com.walmart.sams.services.allocation.configuration.service.model.FlowPlanDetails f where f.last_updated_on between :startDate and :endDate and f.plan_status=:planStatus and f.is_archived=:isArchived and f.cat_desc= :catDesc]
Now last_updated_on column comes from BaseEntity. How to solve it?
JPQL works with entity property names (the fields or getter/setter methods in your Java class) rather than the actual database column names. So if your last_updated_on
is a field in your BaseEntity
class, and your entity uses camelCase for property names, you should use f.lastUpdatedOn
in your query instead of f.last_updated_on
.