我正在使用以下代码来检索我的数据
Criteria cr = session.createCriteria( JobProcess.class );
cr.createAlias("sendMarcs", "sm");
cr.addOrder( Order.desc( "processedTime") );
cr.addOrder( Order.asc( "sm.ats" ) );
它返回所有数据,但所有数据多次出现,673
当它应该是size 列表时返回一个 size 列表99
。我不知道为什么会这样。
是的,我查看了 hibernate 正在使用的 SQL,它是正确的。
此外,如果我删除别名及其顺序,则数据会按预期显示。不相乘,但不排序。
JobProcess.java
@Entity
@Table(name = "jobprocess")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class JobProcess {
@Id
@GeneratedValue
private Long id;
@Basic(optional = false)
@Column(length = 20, name="customerid")
private String customerId;
@Basic(optional=false)
@Column(length = 100)
private String ATS;
@Basic(optional=true)
@Temporal(TemporalType.TIMESTAMP)
@Column(name="timeprocessed")
private java.util.Date processedTime;
@Basic(optional=false)
@Column(length = 1)
private String state;
@Column(length = 300)
private String notes;
@Basic(optional = false)
private long nos;
@OneToMany(mappedBy = "jobprocessid")
private Set<SendMarc> sendMarcs = new HashSet<SendMarc>();
// getters and setters
}
SendMarc.java
@Entity
@Table( name = "sendmarc" )
@Cache( usage = CacheConcurrencyStrategy.READ_WRITE )
public class SendMarc
{
@Id
@GeneratedValue
private BigInteger id;
@Basic( optional = true )
private BigInteger marcfileid;
@Basic( optional = false )
private long jobprocessid;
@Basic( optional = false )
@Column( length = 50 )
private String ats;
// getters and setters
}