JPA hibernate SQL query

Hey i have problem with JPA hibernate SQL query where i serach a elements from one basic attribute and one which is in the basic entity in the List. so i have to compare with array string, beacause i using a multitype search. my JPA one is: @Entity public class Dejavnosti implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id_dejavnosti") private int idDejavnosti; private String naziv; //bi-directional many-to-one association to Lokacija @ManyToOne private Lokacija lokacija; //bi-directional many-to-many association to Produkti @ManyToMany @JoinTable( name="dejavnosti_produkti" , joinColumns={ @JoinColumn(name="dejavnosti_id_dejavnosti") } , inverseJoinColumns={ @JoinColumn(name="produkti_id_produkti") } ) private List produktis; And second: @Entity public class Produkti implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="id_produkti") private int idProdukti; private String naziv; //bi-directional many-to-many association to Dejavnosti @ManyToMany(mappedBy="produktis") private List dejavnostis; and this is my method in EJB which have input List searchwords to compare with 2 attributes one is Dejavnosti.naziv and second Dejavnosti.produktis.naziv: public List Isci(List selectedTexts){ String klic="SELECT c FROM Dejavnosti c INNER JOIN c.produktis dp WHERE " ; for(int i=0;i dejavnosti=em.createQuery(klic,Dejavnosti.class).getResultList(); return dejavnosti; } I don't have errors but sql doesn't work, beacuse return 0 elements but the elemenets are in! i know its a bad code in method but this is my idea :) Thanks for help and to improve my knowledge.

以上就是JPA hibernate SQL query的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏