File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes How to query a value typed object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to query a value typed object" Watch "How to query a value typed object" New topic

How to query a value typed object

Stanley Walker
Ranch Hand

Joined: Sep 23, 2009
Posts: 87
I am trying to learn hibernate and I came across this little problem en route. Any help will be appreciated.

I have created a entity and a value typed object.

My entity is of type Person which is mapped to value object of Address.
The mapping is given below:

My question is can i query from a value typed object? When i query directly from the entity i get the details of the address value object too.
However what if a use case arises where i need to directly query from value object how would i do that.

I tried the below query

However on executing the query from code using the below code:

I get an exception which says:

Exception in thread "main" java.lang.IllegalArgumentException: Parameter address does not exist as a
named parameter in [from valueobject.Address as a where
a.address =:address
at org.hibernate.impl.AbstractQueryImpl.setParameter(
at org.hibernate.impl.AbstractQueryImpl.setString(

Please help.
I agree. Here's the link:
subject: How to query a value typed object
It's not a secret anymore!