• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to query a value typed object

 
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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(AbstractQueryImpl.java:356)
at org.hibernate.impl.AbstractQueryImpl.setString(AbstractQueryImpl.java:643)
at hibernatetrial.run.RunApplication.main(RunApplication.java:43)


Please help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic