[[Template core/front/global/updateWarning is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]
السلام عليكم تواجهنى مشكله فى قراءه من جدولين بينهم علاقه المشكله فى انهوا لا استطيع استخدام restriction فى كلا الجانبين بمعنى نفرض انهوا جدول a بينه علاقه مع جدول b لا استطيع ان اجعله يقرا من الجدول a.id=1 b.id =1
بحثت على الانترنت وجت بعض اللاكواد لكنها لم تعمل ب الشكل المرغوب فيه
public void list_persons() {
s.beginTransaction();
c = s.createCriteria(Person.class, "p");
c.createAlias("p.s1", "s");
c.add(Restrictions.eq("p.id", 1));
c.add(Restrictions.eq("s.id", 1));
List<Person> l= c.list();
for (Person person : l) {
System.out.println(person.getId());
Set<Addreses> sx=person.getS1();
for (Addreses addreses : sx) {
System.out.println(addreses.getId());
}
}
}
لكن الناتج كان
Hibernate: select this_.id as id0_1_, this_.name as name0_1_, s1_.id as id1_0_, s1_.strret as strret1_0_ from Person this_ inner join Addreses s1_ on this_.id=s1_.con where this_.id=? and s1_.id=?
1
Hibernate: select s1x0_.con as con0_1_, s1x0_.id as id1_, s1x0_.id as id1_0_, s1x0_.strret as strret1_0_ from Addreses s1x0_ where s1x0_.con=?
3
1
2
ما كنت اريده هو ان يطبع 1 فى الاستعلام الاول و 1 فى الاستعلام الثانى لكن هو طبع 3 1 2 فى الاستعلام الثانى
تم النشر منذ
السلام عليكم تواجهنى مشكله فى قراءه من جدولين بينهم علاقه المشكله فى انهوا لا استطيع استخدام restriction فى كلا الجانبين بمعنى نفرض انهوا جدول a بينه علاقه مع جدول b لا استطيع ان اجعله يقرا من الجدول a.id=1 b.id =1
بحثت على الانترنت وجت بعض اللاكواد لكنها لم تعمل ب الشكل المرغوب فيه
one_to_many.rar
شارك هذا الرد
رابط المشاركة
شارك الرد من خلال المواقع ادناه