我试图将一个对象传递给我的控制器,该控制器是我从下拉列表中选择的。有2个类:Compte和Client(Compte包含Client类型的属性):
compte.java:
@Entity
@Table(name="COMPTES")
public class Compte implements Serializable {
@Id
@GeneratedValue
private long codeCompte;
private Date dateCreation;
private double solde;
private boolean active;
@ManyToOne
@JoinColumn(name="codeClient")
private Client client;
client.java:
@Entity
@DiscriminatorValue("CLIENT")
public class Client extends Utilisateur {
@OneToMany(mappedBy="client",fetch = FetchType.LAZY,cascade =CascadeType.ALL)
@Fetch(value = FetchMode.SUBSELECT)
private List<Compte> comptes;
addcompteCourant.html
<div class="form-group col-md-8">
<label class="col-form-label">Client</label>
<select class="form-control" name="client"
required="required">
<option value="">Select...</option>
<option th:each="c:${clients}"
th:value="${c.codeUtilisateur}"
th:text="${c.nom}"
></option>
</select>
</div>