• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Fetch only one column using hibernate 3.0

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table(USER) and view(PERSON). These two are related in one-to-one way with PERSON_ID in
both the tables. But User table primary key is USER_ID and not PERSON-ID.
I want to fetch only one column PERSON.CITY and this should be readonly fetch. Anyway person is view.

So if I put one-to-one, then whole object(with 50 col) is fetched which is a overkill. Based on common key,
I only want to fetch one column from PERSON and put that as property of User.
I have this as a formula, but my colleague is opposing this idea since it becomes a sub-query.
So what are the other ways of acheiving this?


I want to get ideas for better ways of implementing this. Thank you for your help.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your view for? If the property it has is related to User, would it not just be easier to access the data via that relationship rather than introducing the overhead of having updatable views?

Personally, I think your sub-query is fine. It will be two queries normally (unless your associations are not lazy). I'm not even sure I'd worry too much about populating all fields over populating just one. It is no quicker from a database point of view selecting one column over selecting all columns, Hibernate hydrating an object is fast code so your only real overhead is the amount of data you sent over the network between the database and server. Do you have a perfomance problem there or is this just a guess that it will help?
 
You got style baby! More than this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic