Pitch your project

Random text


By admin Category Uncategorized, Posted March 21st, 2016
Ebean setup in new IDE environments, IntelliJ

IntelliJ lets you do the whole setup with no commands needed, hence making it easy and time saving. no extra configurations are needed. on other IDEs, all the necessary libraries are downloaded, dependency resolutions performed and project building is handled by the SBT build tool, which is an open source build tool for Java projects.performs same functions as the maven.

The following are steps necessary in creating our first successful table using Ebeans.

Step 1:

  • Start a new maven project

  • Click next, enter project details (group id and artifact id)

  • Once you are done, click finish to generate the new maven project

Step 2:

  • On the pom.xml file, add a dependency to facilitate the use of Ebeans an the database

//dependency for database

The second dependency appears as it is since I’m using PostgreSQL database.
If you are using a MySQL database then one would use


Secondly, create a new package just to make the project look neat, and rename the package as desired.
In the package, create a new java class in the package. Here is a sample:

package entity;

        import javax.persistence.*;

@Table(name = "users")
public class User {


    @Column(name = "user_name", nullable = false)//column name
    String userName;

    @Column(name = "full_name", nullable = false)
    String fullName;

    @Column(length = 60, nullable = false, unique = true)
    String email;

    @Column(length = 50, name = "phone_number")
    String phoneNumber;


The above class defines the columns to be expected in the user table. A table with four columns, user_name, full_name, email and phone_number.


The class name is specified just before the beginning of the class by first notifying the system that you are creating an entity with a specific name, “users” e.g.

@Table(name = "users")

Step 3:

With the entity done, we now need to load the database drivers and enable the table defined in the user.java class in (Step 2) to be generated

In this step we will crate a .properties file called “ebean.properties”


# generate DDL files

# run ddl drops and recreates tables



# json date format

# enable autofetch

# data source default

# postgres
datasource.pg.heartbeatsql=select 1

In this file, the following lines performs the table creation and dropping respectively

# generate DDL files

# run ddl drops and recreates tables

It is however advisable that once the table(s) have been created, comment the lines you’re using the “#” sign. This is because whenever the project runs it will always drop all the tables and create new ones. Otherwise all data already saved in the table will be lost .

Step: 4

Finally, after the Ebean is completely set-up, the entity class well done and all necessary dependencies added in the pom.xml file, create a main class to test if your code runs well.
Use the


In your main class to establish the connection to the database and create the table(s).

The code creates the using ebean.properties to configure the server.


Running the project as it is will not be successful. The system will bring an error message saying “entity not enhanced”

Exception in thread "main" java.lang.IllegalStateException: Bean class entity.User is not enhanced?

the solution to this is to add the Ebean Orm Enhancer.
– go to file
– then settings
– select plugins
– search Ebean ORM enhancer
– install then restart the IDE

Once the IDE is ready, click on the uild tab and select the “Ebean ORM enhancer” then run the main class.

Posted by Bryant Smith

Leave a Reply

Your email address will not be published. Required fields are marked *