Reputation:
How I can save Enum's String value (password) to database? Now I can save only Enum type (ID_CARD
, INTERNATIONAL_PASSPORT
).
My Enum Class
public enum Citizen {
ID_CARD("Id card"),
INTERNATIONAL_PASSPORT("International passport"),
FOREIGN_PASSPORT("Foreign passport");
private String passport;
private Citizen(String passport){
this.passport = passport;
}
public String getPassport(){
return passport;
}
}
@Entity
@Table(name = "citizen")
public class Client implements Serializable{
@Id
@Column(name = "inn")
private long inn;
@Enumerated(EnumType.STRING)
@Column(name = "citizen")
private Citizen citizen;
}
HTML page:
<select th:field="${client.citizen}">
<!--/*@thymesVar id="state" type=""*/-->
<option th:each="state : ${T(models.client.Citizen).getCitizens()}"
th:value="${state}" th:text="${state}">
</option>
</select>
I wanna save like th:value="${state.passport}" th:text="${state.passport}"
Upvotes: 0
Views: 202