0
我有3個實體客戶,數據和信息。實體之間的關係是oneToMany是這樣的:使用MySQL Query獲取客戶信息
public class Customer implements Serializable {
...
@OneToMany
private List<Data> datas;
...
public class Data implements Serializable {
...
@OneToMany(mappedBy = "dataBase")
private List<Information> informations;
@ManyToOne
private Customer customer;
..
public class Information implements Serializable {
...
@ManyToOne
private Data dataBase;
...
現在我希望每個登錄的客戶只能看到自己的信息。 我想用abql使用JPQL命名查詢。 所以我寫的信息
public List<Information> getInformations() {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
HttpSession session = request.getSession(false);
String idCustomer = (String) session.getAttribute("idCustomer");
Customer cust = customerBusinessLocal.findById(idCustomer);
List<Data> datas=dataBusinessLocal.findByCustomer(cust);
return InformationBusinessLocal.informations(datas);
}
的manged Bean的這個方法,但我得到javax.ejb.EJBTransactionRolledbackException
如何使用教程開始? – Strawberry
你知道任何有用的嗎? –
我相信任何使用適當關鍵字找到的教程都會很有用。 – Strawberry