在 Java 中,我有一个列表,我想对它进行排序。有没有一种方法可以为我做到这一点?
要排序的列表List<Caution>
我想使用lbEtatCaution
实体:
@Entity
@Table(name="TG_CAUTION")
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Caution implements Serializable {
private static final long serialVersionUID = 1L;
@Transient
public static String NOM_DOSSIER_CAUTION_DEFAULT =" ";
@Id
@SequenceGenerator(name="TG_CAUTION_IDCAUTION_GENERATOR", sequenceName="SID_CAUTION" , allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="TG_CAUTION_IDCAUTION_GENERATOR")
@Column(name="ID_CAUTION")
private long idCaution;
@Column(name="DT_CAUTION")
private Timestamp dtCaution;
@Column(name="DT_ETAT")
private Timestamp dtEtat;
@Column(name="DT_RECEPTION")
private Timestamp dtReception;
@Column(name="MT_CAUTION" ,columnDefinition="number")
private double mtCaution;
@Column(name="RF_DOSSIER")
private String rfDossier;
//bi-directional many-to-one association to TcEtatCaution
@ManyToOne
@JoinColumn(name="CD_ETAT_CAUTION")
private EtatCaution tcEtatCaution;
//bi-directional many-to-one association to TgAgentCaution
@ManyToOne
@JoinColumn(name="ID_AGENT")
private AgentCaution tgAgentCaution;
//bi-directional many-to-one association to TgCaution
@ManyToOne
@JoinColumn(name="ID_CAUTION_REMPLACEE")
private Caution tgCaution;
//bi-directional many-to-one association to TgCaution
@OneToMany(mappedBy="tgCaution")
private List<Caution> tgCautions;
//bi-directional many-to-one association to TgCompteCaution
@ManyToOne
@JoinColumn(name="ID_COMPTE_CAUTION")
private CompteCaution tgCompteCaution;
//bi-directional many-to-one association to TgHistoCaution
@OneToMany(mappedBy="tgCaution")
private List<HistoCaution> tgHistoCautions;
//bi-directional many-to-one association to TgRejet
@OneToMany(mappedBy="tgCaution")
private List<Rejet> tgRejets;
//bi-directional many-to-one association to TgApprehension
//@OneToMany(mappedBy="tgCaution")
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name="ID_CAUTION")
private List<Apprehension> tgApprehensions;
//bi-directional many-to-one association to TgBordereau
@OneToMany(mappedBy="tgCaution")
private List<Bordereau> tgBordereaus;
//bi-directional many-to-one association to TgTransfertSirepa
@OneToMany(mappedBy="tgCaution")
private List<TransfertSirepa> tgTransfertSirepas;
public Caution() {
}
//getters and setters
}
实体注意事项:
@Entity
@Table(name="TC_ETAT_CAUTION")
public class EtatCaution implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name="CD_ETAT_CAUTION")
private long cdEtatCaution;
@Column(name="LB_ETAT_CAUTION")
private String lbEtatCaution;
@Column(name="MN_ETAT_CAUTION" , columnDefinition="char")
private String mnEtatCaution;
public EtatCaution() {
}
//getters and setters
}