2

Hello EveryOne,

 @Entity
    public class Parent {

        @EmbeddedId
        private Child child;

        @Column(name = "TEST")
        private long test;

       getter setter

    }

and chlid class

@Embeddable
public class Child {

    @Column(name = "TEST1", length = 50, nullable = false)
    private String test1;

    @Column(name = "TEST2", length = 50, nullable = false)
    private String test2;

getter setter and hasCode and Equal function 
}

There are model with Embeddable Composite Key.

String hql = "select v from Parent v WHERE v.child.test1= abc";
        List<Parent> list2 = sessionFactory.getCurrentSession()
                .createQuery(hql).list(); 

and this is query.

if i am put where clause on child.test1 then it will return null,null as record.but if i am remove a where clause then it will be map fine with Parent.

Please Help me.

snieguu
  • 2,073
  • 2
  • 20
  • 39
Charnjeet Singh
  • 3,056
  • 6
  • 35
  • 65
  • 1
    It should work if `abc` is a proper value which matches some record in database. Can you turn on SQL logging to see the query that actually goes into database? – Predrag Maric Apr 23 '15 at 08:40

0 Answers0