Javax.el.PropertyNotFoundException: 属性 'ticket_id' 在类型 java.lang.Integer 上找不到
Javax.el.PropertyNotFoundException: Property 'ticket_id' not found on type java.lang.Integer
TICKET_ID 列的数据类型在数据库中为 int。还是这个问题persists.Set getter/setters public 太。
型号
@Id
@Column(name = "TICKET_ID")
private Integer ticket_id;
public Integer getTicket_id() {
return ticket_id;
}
public void setTicket_id(Integer ticket_id) {
this.ticket_id = ticket_id;
}
@Column(name = "PRIORITY")
private String priority;
HQL
Session session = sessionFactory.openSession();
String hql = "Select ticket_id from Ticket";
@SuppressWarnings("unchecked")
List<Ticket> ticketList = session.createQuery(hql)
.list();
session.close();
return ticketList;
JSP
<th>Category</th>
</tr>
<c:forEach items="${ticketList}" var="usr">
<tr>
<td><c:out value="${usr.ticket_id}" /></td>
<td>Priority</td>
异常
javax.el.PropertyNotFoundException: Property 'ticket_id' not found on type java.lang.Integer
您的查询是
select ticket_id from Ticket
该查询 returns 包含票证 table 中所有票证 ID 的 List<Integer>
,而不是 List<Ticket>
。如果你想要一个门票列表,查询应该是
select t from Ticket t
您还应该努力遵守 Java 命名约定:ticketId
,而不是 ticket_id
。
TICKET_ID 列的数据类型在数据库中为 int。还是这个问题persists.Set getter/setters public 太。
型号
@Id
@Column(name = "TICKET_ID")
private Integer ticket_id;
public Integer getTicket_id() {
return ticket_id;
}
public void setTicket_id(Integer ticket_id) {
this.ticket_id = ticket_id;
}
@Column(name = "PRIORITY")
private String priority;
HQL
Session session = sessionFactory.openSession();
String hql = "Select ticket_id from Ticket";
@SuppressWarnings("unchecked")
List<Ticket> ticketList = session.createQuery(hql)
.list();
session.close();
return ticketList;
JSP
<th>Category</th>
</tr>
<c:forEach items="${ticketList}" var="usr">
<tr>
<td><c:out value="${usr.ticket_id}" /></td>
<td>Priority</td>
异常
javax.el.PropertyNotFoundException: Property 'ticket_id' not found on type java.lang.Integer
您的查询是
select ticket_id from Ticket
该查询 returns 包含票证 table 中所有票证 ID 的 List<Integer>
,而不是 List<Ticket>
。如果你想要一个门票列表,查询应该是
select t from Ticket t
您还应该努力遵守 Java 命名约定:ticketId
,而不是 ticket_id
。