hi all, i am newbei to Hibernate, i am working on a project, it has two masters one is Being and another one is Debit. in Being master i am storing just beingName, in Debit master i am storing debitName and all the associated beingIds.
i am using three tables to store the content: being: beingId long primary key, auto generated beingName varchar(100)
debit: debitId long primary key, auto generated debitName varchar(100)
debit_being: debitId long forieg key beingId long forieg key
to persist being details i am using Being.hbm.xml while user adding a being he will just enter beingName and submits, that will store in being table through Being.hbm.xml file
to persist debit details i am using debit.hbm.xml while user adding a debit he will enter debitName and select multiple beingNames from the selection list and submits, now the debitName is storing to debit table, then newly generated debitId and associated beingIds are storing in debit_being table.
now when i am listing the debits i need to display debits with associated beingNames rather beingIds so, is it possible to define in the mapping document (i,e Debit.hbm.xml) so that i can retrieve all the associated Being objects of perticular Debit object. or do i have to write hql query to join the tables.
If I understand your question correctly, you most certainly can. In Hibernate you must map the domains using an association. This will enable you to use the session.find or better still the Query object to return the values, i.e session.get(..) and that the objects will be contain references to each other.
An association can be performed using a idbag, set, map, bag for example. Toplink works differently though, where the 'container' maintains the references between objects.