I get error in this code :
```java
    public List<UserDiscountEntity> findUserDiscountAssignments(long discountId, long userId) throws DBException {
        QueryManager<UserDiscountEntity> qm = new QueryManager<>();
        return qm.executeQuery(
                "select UserDiscountEntity where deletedAt is null and discount.id = ? and user.id = ?",
                discountId, userId
        );
    }
```

related class :
```java
package ir.oddrun.domain.entity.discount;

import ir.oddrun.domain.dto.discount.DiscountDTO;
import ir.oddrun.domain.util.ConfigUtil;
import ir.oddrun.domain.util.Constants;
import ir.oddrun.external.util.DateUtil;
import ir.oddrun.nazdika.core.util.EntityUtil;
import ir.oddrun.nazdika.hibernate.entity.BaseEntity;
import ir.oddrun.nazdika.hibernate.entity.gamification.UserEntity;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;

@Entity()
@DynamicUpdate
@DynamicInsert
@Table(name = "t_user_discount", uniqueConstraints = {
        @UniqueConstraint(columnNames = {"fk_user", "fk_discount"})
})
public class UserDiscountEntity extends BaseEntity {


    @Id
    @GeneratedValue(generator = "user-discount-seq-gen")
    @GenericGenerator(name = "user-discount-seq-gen", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
            parameters = {
                    @org.hibernate.annotations.Parameter(name = "optimizer", value = "pooled"),
                    @org.hibernate.annotations.Parameter(name = "increment_size", value = "1"),
                    @org.hibernate.annotations.Parameter(name = "sequence_name", value = "USERDISCOUNTSEQ")
            })
    @Column(name = "c_id")
    private Long id;

    @ManyToOne
    @JoinColumn(name = "fk_user", nullable = false)
    private UserEntity user; // Reference to UserEntity

    @ManyToOne
    @JoinColumn(name = "fk_discount", nullable = false)
    private DiscountEntity discount; // Reference to DiscountEntity

    @Column(name = "c_activation_time")
    private Date activationDate;

    @Column(name = "c_use_time")
    private Date useDate;

    @Column(name = "c_enabled")
    private boolean enabled = true;
    @Transient
    private boolean seen;

    @Column(name = "c_deleted_at")
    private Date deletedAt;


    // Constructors, Getters, and Setters
    public UserDiscountEntity() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public UserEntity getUser() {
        return user;
    }

    public void setUser(UserEntity user) {
        this.user = user;
    }

    public DiscountEntity getDiscount() {
        return discount;
    }

    public void setDiscount(DiscountEntity discount) {
        this.discount = discount;
    }

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    @Transient
    public Long getExternalId() {
        return EntityUtil.INSTANCE.convertIdToExternalId(id);
    }

    public DiscountDTO toDTO(boolean showPrivates) {
        DiscountDTO dto = getDiscount().toDTO(showPrivates);
        dto.setId(getExternalId());
        dto.setActivated(isActivated());
        dto.setActivatedTime(getActivationDate());
        dto.setUsed(used());
        dto.setUsedTime(getUseDate());
        dto.setEnabled(isEnabled());
        if(getDiscount().getCategory() != null)
            dto.setPurchasableItemCategoryId(getDiscount().getCategory().getExternalId());
        if(getDiscount().getPurchasableItem() != null)
            dto.setPurchasableItemId(getDiscount().getPurchasableItem().getExternalId());
        dto.setExpiryText(
                getDiscount().getExpiryTime() == null ? ConfigUtil.getInstance().getLocalizedMessage(Constants.Discount.NO_EXPIRY_MESSAGE) :
                    used() ? ConfigUtil.getInstance().getLocalizedMessage(Constants.Discount.DISCOUNT_USED_MESSAGE) :
                        expired() ? ConfigUtil.getInstance().getLocalizedMessage(Constants.Discount.EXPIRED_MESSAGE) :
                        ConfigUtil.getInstance().getLocalizedMessage(Constants.Discount.EXPIRE_TIME_MESSAGE) + ": " +
                                DateUtil.getDaysOrMonthOrMinutes(getDiscount().getExpiryTime().getTime()) + " دیگر"
        );
        dto.setSeen(isSeen());
        dto.setExpireSoon(!expired() &&
                (getDiscount().getExpiryTime() != null && ChronoUnit.DAYS.between(new Date().toInstant(), getDiscount().getExpiryTime().toInstant()) == 0));
        return dto;
    }

    private boolean used() {
        return useDate != null;
    }

    public void use() {
        this.useDate = Calendar.getInstance().getTime();
    }

    public Date getActivationDate() {
        return activationDate;
    }

    public void setActivationDate(Date activationDate) {
        this.activationDate = activationDate;
    }

    public void activate() {
        this.activationDate = Calendar.getInstance().getTime();
    }

    public boolean isActivated() {
        return activationDate != null;
    }

    public boolean expired(){
        return getDiscount().expired();
    }

    public boolean started(){
        return getDiscount().started();
    }

    public Date getUseDate() {
        return useDate;
    }

    public void setUseDate(Date useDate) {
        this.useDate = useDate;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserDiscountEntity that = (UserDiscountEntity) o;
        return Objects.equals(id, that.id);
    }

    public void setSeen(boolean seen) {
        this.seen = seen;
    }

    @Transient
    public boolean isSeen() {
        return seen;
    }

    public Date getDeletedAt() {
        return deletedAt;
    }
    public void setDeletedAt(Date deletedAt) {
        this.deletedAt = deletedAt;
    }

    @Transient
    public boolean isValidUserDiscountCombination() {
        if (user == null || discount == null) {
            return false;
        }

        boolean userIsPage = isPage(user);

        if (discount.isGeneral()) {
            return true;
        }

        if (discount.isPageSpecific()) {
            return userIsPage;
        }

        if (discount.isAccountSpecific()) {
            return !userIsPage;
        }

        return true;
    }

    private boolean isPage(UserEntity user) {
        return user != null && user.getPhone() == null;
    }

    @PrePersist
    @PreUpdate
    public void validateUserDiscountCompatibility() {
        if (!isValidUserDiscountCombination()) {
            throw new IllegalStateException(
                    "Cannot assign " +
                            (discount.isPageSpecific() ? "page-specific" : "account-specific") +
                            " discount to " +
                            (isPage(user) ? "page" : "account")
            );
        }
    }
}
```