Step 1 Sort the beans. Soak overnight in cold water to cover generously.
Step 2 The next day, drain and rinse the beans. Bring a large pot with fresh salted water to a boil. Add the beans and turn down the heat; simmer until tender, about 1 1/2 to 2 hours. Drain and cool. Heat the oven to 350 degrees.
Step 3Layer the beans and onions in a 9-by-13-inch baking dish. Have ready about 1 teaspoon salt and 1 teaspoon freshly ground black pepper. First cover the bottom of the dish with a layer of onion slices. Drizzle with olive oil and sprinkle with salt and pepper. Add beans to cover the onions and sprinkle with olive oil, salt and pepper. Continue making layers in this fashion until the dish is full, finishing with a layer of beans and using the 1 teaspoon each salt and pepper. The oil should come to just below the top layers of beans and onions.
Step 4Cover and bake until the beans are very tender, about 30 minutes.
Step 5Remove the cover and bake 15 minutes longer, until beans start to turn golden brown. To serve, remove spoonfuls of beans and onions from the baking dish with a slotted spoon, letting the oil drain off. Season to taste with additional salt and a generous amount of black pepper. Offer on small plates as an appetizer with fresh bread or garlic toast.