If using dried beans, soak them overnight, then drain and rinse.
Heat olive oil in a large pot over medium heat.
Sauté diced onion, sliced carrots, and chopped celery for 5 minutes.
Add minced garlic and cook for 30 seconds.
Add beans, shredded ham, chicken broth, bay leaf, thyme, and black pepper.
Bring to a boil, then reduce heat and simmer: 1½ hours for dried beans or 30–35 minutes for canned beans.
Remove bay leaf, taste, and adjust salt as needed.
Lightly mash some beans in the soup for a creamier texture.
Preheat the oven to 375°F (190°C) and grease a baking pan.
Mix cornmeal, flour, sugar, baking powder, and salt in a bowl.
Stir in milk, melted butter, and egg until just combined.
Pour batter into the greased pan and bake for 20–25 minutes until golden.
Serve the soup ladled into bowls, topping or siding with warm cornbread.