Book Image

Advanced Java EE Development with WildFly

By : Deepak Vohra
Book Image

Advanced Java EE Development with WildFly

By: Deepak Vohra

Overview of this book

<p>This book starts with an introduction to EJB 3 and how to set up the environment, including the configuration of a MySQL database for use with WildFly. We will then develop object-relational mapping with Hibernate 4, build and package the application with Maven, and then deploy it in&nbsp;WildFly 8.1, followed by a demonstration of the use of Facelets in a web application.</p> <p>Moving on from that, we will create an Ajax application in the Eclipse IDE, compile and package it using Maven, and run the web application on WildFly 8.1 with a MySQL database. In the final leg of this book, we will discuss support for generating and parsing JSON with WildFly 8.1.</p>
Table of Contents (18 chapters)
Advanced Java EE Development with WildFly
Credits
About the Author
About the Reviewers
www.PacktPub.com
Disclaimer
Preface
Index

Deleting a table row


In this section, we will delete a table row from the CATALOG table. Perform the following steps to accomplish this:

  1. Create a HQL query String for the Catalog instance to delete the table row using the following line of code:

    String hqlQuery = "from Catalog as catalog WHERE catalog.edition='March-April 2005'";
  2. As in find.jsp and update.jsp, get List for Catalog instances. As only one Catalog instance has edition set to March-April 2005, we only need to get the first Catalog instance from List. To do so, use the following code:

    Catalog catalog = (Catalog) list.get(0);
  3. Create a Transaction object with beginTransaction().

  4. Delete the Catalog instance from the Session with the delete method, which doesn't delete the Catalog instance from the database. Invoke the commit() method of the Transaction object to save the Session state in the database, which deletes the corresponding table row from the CATALOG table.

  5. Optionally, using the following code, output a message to indicate deletion...