This essay developed out of conversations I've had with several other programmers about why Java smelled suspicious. It's not a critique of Java!
Sycorax - complete tutorials
Programming Tutorials
" Java provides the industry - software companies and customer alike , an opportunity to create a true open computing environment where software is portable,
and customers benefit from increase competition. "
Java and the Future
December 1, 2008-LEJB 3.1: EJB New and Improved!
The EJB 3.0 specification was a huge improvement from what you were used to in the early versions of EJB. Available as an early draft, EJB 3.1 has many more features and is even easier to use.
December 1, 2008-Should Java Assert that Network I/O Can't Occur on the UI Thread?
Doing network I/O on the user interface (UI) thread is bad. Most developers know that and can tell you why; unfortunately, it's still done.
Register now to recieve special alert and latest technology news!
The Remote Interface - The first part of creating the BookRemote EJB is to define its remote interface. This interface specifies what business methods a client is allowed to invoke on the EJB. Clients interact with the bookstore's createBook( ) and findBook( ) methods to manipulate Book entities:
import javax.ejb.Remote;
@Remote
public interface BookRemote {
public void createBook(Book book);
public Book findBook(int id);
}
The Bean Class
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
public class BookBean implements BookRemote{
@PersistenceContext
(unitName="book")
private EntityManager manager;
public void createBook(Book book) {
manager.persist(book);
}
public Book findBook(int pKey) {
return manager.find(Book.class, pKey);
}
}
The Bean Class
import javax.persistence.*;
@Entity
@Table(name="BOOK")
public class Book implements java.io.Serializable{
private int id;
private String name;
private int price;
@Id
@Column(name="ID")
public int getId( ) { return id; }
public void setId(int pk) { id = pk; }
@Column(name="NAME")
public String getName( ) { return name; }
public void setName(String str) {name = str; }
@Column(name="PRICE")
public int getPrice( ) { return price; }
public void setPrice(int pr) { price = pr; }
}
The persistence.xml File
<persistence>
<persistence-unit name="book">
<jta-data-source>java:/BookDB</jta-data-source>
</persistence-unit>
</persistence