我的实体Bean方法
public List<Object> Available_RoomType(String startDate, String EndDate, String name) {
List<Object> arr_room = em.createNativeQuery("select T.* "
+ "from RoomType T"
+ " inner join Room R on R.RoomTypeID = T.RoomTypeID"
+ " left join Booking B on B.RoomID = R.RoomID"
+ " where T.Name = '" + name + "' and"
+ " ((('" + startDate + "' not between B.checkindate and B.checkoutdate) and"
+ " ('" + EndDate + "' not between B.checkindate and B.checkoutdate)) or"
+ " (B.BookingID is null))" , Roomtype.class).getResultList();
return arr_room;
}
当我在测试它时从oracle sql开发人员运行它时,此查询返回一行。 我的JSP页面。
我使用实体bean的方法,它返回一个大小为0的行。
List<Object> result = guestSession.Available_RoomType(startDateString, endDateString, name);
List<Roomtype> new_room;
List<? extends Object> list = result;
new_room = (List<Roomtype>) list;
%>
<table>
<%if(new_room!=null){
for(Roomtype r : new_room){%>
<tr>
<td><%= r.getName() %></td>
<td><%= r.getDescription() %></td>
<td><%= r.getPrice() %></td>
</tr>
<%}
}%>
</table><%
}
%>
但是当我在foreach中使用它时,为了获取属性,编译器跳转到foreach并且没有显示任何属性.Page变为空。请帮忙