简体   繁体   中英

hibernate, query on embeddable object

Is it possible to query on Embeddable object from separate query?

Eg, we have

@Entity
class Person{
...
@Embedded
private Address address;
...
}


@Embeddable
class Address{
private String street;
...

}

is it possible to create hql-query like this :

getHibernateTemplate.find("from Address"); ?

Thank you in advance.

It is not possible since embedded object does not have table associated with it without a context of outer object. For example, you can have Address embedded in different entities mapped on different tables. How would you figure which table to use?

It may be possible, however, to do something like

select p.address from Person p

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM