Skip to content

Making your old java classes orman entities

ahmetalpbalkan edited this page Jun 4, 2011 · 6 revisions

In your programs, you model your real-world entities as Java classes. Therefore, in this framework you should have your database entities as Java objects. For example, we will have students in our database. In usual Java you should have something like:

class Student {
    public int id;
    public String name;
    public Date registrationDate;
    public float gpa;
}

In order to convert this POJO (plain old Java object) class to an ORMAN entity you need to add a few things.

@Entity    
class Student extends Model<Student>{
    public int id;
    public String name;
    public Date registrationDate;
    public float gpa;
}

Let's understand what's going on here. Using @Entity annotation, you have indicated that this class is an entity for the framework.

Clone this wiki locally