From the course: Java Database Access with Hibernate

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Plain old Java object (POJO)

Plain old Java object (POJO) - Java Tutorial

From the course: Java Database Access with Hibernate

Start my 1-month free trial

Plain old Java object (POJO)

- [Instructor] The last major piece to the puzzle for getting everything setup to be able to use a database, and use Hibernate, is to take a look at the class file that was created, or the JavaBean, or the Plain Old Java Object. It has a lot of different names. But, let's open Message.java. Remember, this was generated automatically when I went through the Hibernate wizard. On line nine, we declare our class, public class Message. Then, on lines 12 and 13 are our instance variables. We have private Short id, and private String message. As I stated before, line 15 has our default constructor which is required by Hibernate. Line 18 has another constructor that allows us to create a message when we have a String message from the user. Let me scroll down a little bit so we can see our getter and setter methods. Line 22, we're saying getId, which returns the Id field. Line 26 allows us to set the Id. 29 gets the message, and 33 allows us to return the message. This was created by using the…

Contents