Hibernate findByexample Issue

1.5k views Asked by At

I have two table User and Address Table

And their relation in HBM is

<!-- bi-directional one-to-one association to Address -->
    <one-to-one
        name="user"
        class="address"
        outer-join="auto"
    />

So when I set Address Pojo in User Pojo and call findByExample for User Pojo.

It ignore the Address Pojo

2

There are 2 answers

0
JB Nizet On

The reference manual says:

Version properties, identifiers and associations are ignored.

But it also says:

You can even use examples to place criteria upon associated objects.

List results = session.createCriteria(Cat.class)
    .add( Example.create(cat) )
    .createCriteria("mate")
        .add( Example.create( cat.getMate() ) )
    .list();
0
dcernahoschi On