• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hibernate mapping a view no primary key

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a view which comprises of joining 4 table and it does not have a primary keys, this view is just used for display purpose. I want it to be managed by hibernate, I did some search and found that it is not able to have a view mapped to a pojo with out a primary key, one solution is to create a composite key with all the columns in the view and then use @Embeddable annotation, I did this and it worked fine for me. But is there a way to tell hibernate that this POJO is a select only kind of POJO and I will never do a insert/update so no need of a primary key. Or are there any other options that I can try. thanks
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andy, Did you take a look at "ResultSetTransformers" in Hibernate.
Check for some examples here.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one way to accomplish this is to use constructor expression in your JPQL, so for example, you could do a



in this example, example.EmpMenu class does not have to be an entity, it can be just a pojo, it must have proper constructor to match the constructor expression
in the JPQL.

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

robert walker wrote:one way to accomplish this is to use constructor expression in your JPQL, so for example, you could do a



in this example, example.EmpMenu class does not have to be an entity, it can be just a pojo, it must have proper constructor to match the constructor expression
in the JPQL.



Can you please expalin your logic?
 
They weren't very bright, but they were very, very big. Ad contrast:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic