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