如何在 JPQL 的 JPA 的 IN 子句中使用字符?例如在 oracle DB 我有这个查询:
select * from channel o where channel_mode IN ('O','R')
通道模式是 DB 中的 char 列。
我从 JPQL 收到一个错误invalid IN argument[o]
,它是一个字符。
@Chris 这是 JPQL:
typeMasterList = em.createQuery("select object(o) from ChannelRequest as o where o.crqState IN ('O','R') and o.crqMode = 'B' ").getResultList();
实体 ChannelRequest 是:
@Entity
@Table(name = "CHANNEL_REQUEST")
@XmlRootElement
public class ChannelRequest implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(name = "CRQ_ID")
private Long crqId;
@Size(max = 100)
@Column(name = "CRQ_QUEUE")
private String crqQueue;
@Size(max = 160)
@Column(name = "CRQ_DATA")
private String crqData;
@Column(name = "CRQ_STATE")
private Character crqState;
@Column(name = "ACTIVE_FLAG")
private Short activeFlag;
@Column(name = "ENABLED")
private Short enabled;
@Size(max = 100)
@Column(name = "CRQ_ADDRESS")
private String crqAddress;
@Column(name = "CRQ_MODE")
private Character crqMode;
@Column(name = "DCO")
@Temporal(TemporalType.TIMESTAMP)
private Date dco;
@Column(name = "DLUO")
@Temporal(TemporalType.TIMESTAMP)
private Date dluo;
@OneToMany(mappedBy = "rpmrqCrId")
private Collection<RpmRequest> rpmRequestCollection;
@JoinColumn(name = "MM_ID", referencedColumnName = "MM_ID")
@ManyToOne
private MediumMaster mmId;
@JoinColumn(name = "MC_ID", referencedColumnName = "MC_ID")
@ManyToOne
private MediumChannel mcId;`enter code here`
这是我得到的错误:invalid IN expression argument [O], expected argument of type [java.lang.Character]