Q:

Object Oriented Programming: More than just basic objects

I seem to find all documentation regarding OOP too basic or too advanced. I'm trying to solve a specific problem and I can't get a nice solution without having to use Singletons or global instances or the such.
I'm trying to create a DB based application: I have a DB with Boxes that are stored in some Location. So I created to tables: Boxes and Locations
BOXES
| id | Name | Location |
------------------------
| 1  | AA   |    1     |
| 2  | AB   |    2     |

LOCATIONS
| id | Name         | 
---------------------
| 1  | Garage       |
| 2  | Living Room  |

When trying to bring this to an Java application, I want to have a Box class that I can instantiate for every box and locations that I have in DB and put them in a list.
My question is: how do I design Box and Location Classes?
The immediate approach would be:
class Box {
   int id;
   String name;
   Location location;
}

Class Location {
   int id;
   String name;
}

But then, how can I operate Locations properly? I still want to manage them from my application and have a tool that would return Location objects given an id.
Something like:
Location loc = new Locations.getById(1);

And it would query an something (like n enum) that would return the appropriate, filled, object. 
Can anyone point me to resources that would explain this kind of services and solutions? 

A:

Even though your question title indicates OO design, from reading your question I get a sense that you're more interested in the general way to go about handling persistent objects in your application.  
Just to be clear...this isn't an OO design answer, even though OO concepts will be a part of your solution.
Here are some of the ways you can accomplish your goals:

(This is an ANTI-EXAMPLE...would not recommend this for any other reason than trying to really understand why you should NOT be doing it...) Write some kind of god object that builds SQL strings and runs them using JDBC.  Yuck...
Use JDO or JPA.  These are frameworks where you basically don't write SQL at all.  Instead you declare objects which represent data you want to store.  There are then classes/services available which perform CRUD (Create, Retrieve, Update, Delete) operations on your objects and also provide mechanisms for performing transactions.
Use an ORM (Object Relational Mapping) framework which requires you to map your SQL tables to your Java Objects.  Then, you can write paramaterized SQL queries in a localized place.  For example, this allows you to make objects like BoxService.get().getObjectByName(name).location;  The most popular option for this seems to be hibernate but a good alternative is mybatis.  Using ORMs is personally the route I would chose, but for me, it is just a preference.  I wouldn't be able to give a detailed argument for why an ORM would be better than JDO or JPA.

That should be enough info to get you started.  If you're looking to take a real do-it-yourself approach then see one of the other answers.  My answer is specifically an overview of what developers commonly do.

