Hibernate version:
3.1
Mapping documents:
Using annotations
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
MySQL 5.0.18
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A
I run across this often and don't know the best practice. I have an association (say many-to-one) between object1 and object2. object1 has-a object2. For our application, when we deal with object1, we are really only interested in a couple fields in object2 (e.g. first name and last name properties). object2 is a huge object and I'd rather not have to load all of it when loading object1. I just want the name fields of object2, but I'd like those fields to be loaded in the same select as the object1 load.
How do people handle this? I've looked at secondary tables and wasn't sure that was what I wanted. I thought I read somewhere that we could map a single table to mulitple entities (so we could have a "mini" object2), but again, not sure that's what I want or allowed with annotations (plus the duplication of the mapping properties in the mini). I also read that if one can't figure out how to do something, it can probably be handled by User types. Never used those.
Any help is appreciated.
Jim
|