Dropwizard – Tutorial to write APIs to read/write from database using hibernate

Please go through the first part of this tutorial to set up your dropwizard project. For this project, we will assume you have a working dropwizard project.

Add dependency to your pom.xml

Please add dependency of hibernate and mySQL-connector to your pom.xml

Create Info Table in MySql

Add some content to your table. In my case, table content should look like:

Screen Shot 2018-07-12 at 6.58.47 PM.png

Add Info Model

Add Info.java in src/main/java. Your info.java should look like:

Add InfoDao

Add InfoDao.java in src/main/java. Your info.java should look like:

Add Database Configuration

Update Configuration.java and dev.yml, it should look like the files below:

Add following properties to dev.yml

Add API to display all the Employees

Update MyApplication.java to register hibernate


Dropwizard Hibernate

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: