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.

Java application

Java application - Java Tutorial

From the course: Java Database Access with Hibernate

Start my 1-month free trial

Java application

- [Instructor] At this point, we've created our configuration file. We used reverse engineering to create our mapping file, the message.hbm.xml. We created our class file, the message.java, which is what you see here. Now, I want to go back to my main program, where I'm going to ask the user to enter in a message. I'll read that message in, and then I'm going to establish a session with the database using hibernate, and then, save my message to the database. At the end of the program, I'll just print out all the messages that exist in the database, which should grow as we run the program multiple times. Because the whole point of this activity was to allow us to persist the messages from one session to the next, from one execution of our program to the next. So we run it a few times, we should see a few messages. All right, let's go over to the HelloWorldExample.java, which right now is just a template, an empty shell, and we're going to add information that we need. We're going to…

Contents