• 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

How to implement light weight version of an entity using hibernate annotations?

 
Greenhorn
Posts: 17
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In our project, we have an entity 'Restaurant' with nearly 30 fields(some have relationships with other entities). So, every time we need a 'Restaurant' object even for a few fields, all the others are retrieved. This effects the performance. So, in the hbm file we wrote two classes both pointing to the same physical class and same table in database as shown below.



In one of the DAO implementations, we are using Criteria which takes 'RestaurantLite' and returning list of restaurants as we have to work with only restaurant objects as shown below.



Now we want to remove all hbm files and use annotations. So how the same can be done using annotations for entites? Do we need to create an extra class 'RestaurantLite'? If then, how the above criteria returns 'Restaurant' objects??
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most straightforward way to do this is to map properties you don't use often as lazy:Hibernate would not load such properties initially; instead they'll be loaded on demand (when first accessed).

Did you already consider this approach?
reply
    Bookmark Topic Watch Topic
  • New Topic