When using unidirectional or bidirectional relationship? (I hope it was the right question... )
I think it's all about your needings.
Personally i try to avoid bidirectional relationship if I don't need them so I can simplify mapping and entities.
You could have a simple Case - Pencil 1:n relationship where you need pencils in a particular case but you don't need where is a particular pencil.
But you could have a Customer - Bill 1:n relationship where you need all bills for a customer AND the customer of a particular bill.
Il'll take an example from the project I'm working on:
I have one entity rapresenting user data in the system (call that User) and another entity rapresentig some options setted from the user (call them UserOption).
User and UserOption are related in a 1:n relationship. When i access a User need to read UserOptions data so i mapped a OneToMany relationship User -> UserOption. It never happens in my logic to access some UserOption and look for owning user than i didn't mapped inverse ManyToOne relationship UserOption -> User.
If you don't need inverse relationship you could not map that (so you don't need to work on configuring inverse side... I make always mistake when I write them )
It will only work with a foreign key of some sort, there must be a way of tracking the relationship in the db. The simplest way is to have the foreign key in the "many" side of the relationship, otherwise a join table is needed. here is an example
You will need to fill in all the other stuff needed in a good bean, but the above should give you an idea of how the relationship looks. You will also have to decide who will manage the relationship and may have to add a "mappedBy=XXX" to the non-managing side.
Btw, in the above example the UserOption table will end up with a user_id column which will be the foreign key pointing to the User and that's how the relationship will be tracked.