bro, you don't have to know J2EE to learn Java EE 5. naay mga documentation ang Sun nga introductory gyud.
here:
http://java.sun.com/javaee/5/docs/tutorial/doc/
here are some key features sa ila differences:
Java EE 5:
- reduced use of deployment descriptors
- use of annotations instead of deployment descriptors
- Entities are separated from the EJBs
- Entity is included under the persistence layer
- Entities are POJOs (Plain Old Java Objects) w/c represents database tables
- Entities are mapped to the database simply using annotations
- User authorization and authentication are defined using annotations
- JPA (Java Persistence API)!!!!!!!!!!!!!!!!!!
Basically, ang enhancement sa Java EE 5 kay ang pag-gamit sa
annotations. Na-reduce gyud pay-ayo ang paggamit ug XML para sa deployment descriptors. Sauna (J2EE) halos taga-lihok gabuhat kay ug XML. Karon mas sayun na lang.
ex. (naa kay entity nga Customer)
@Entity
@Table(name="customer")
@NamedQuery(name="Customer.findByName", query="SELECT c FROM Customer c " +
"WHERE c.firstName = :firstName AND c.lastName = :lastName")
public class Customer implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name="first_name", nullable=false)
private String firstName;
@Column(name="last_name", nullable=false)
private String lastName;
@OneToOne(cascade={CascadeType.ALL})
@JoinColumn(name="add_id")
private Address address;
<accessors here>...
}
Ang kanang mga statements nga naay "@" mao nay mga annotations. Gikan na sa J2SE. Maoy gipagamit nila karon para mas sayon na lang. Dili na ka kinahanglan ug deployment descriptors - although you can still use one if needed or depende sa imo specs.
Ang kani nga entity nga Customer ga-represent lang gyud ni sa imo table nga CUSTOMER sa database. wala kay business logic dapat ibutang diri kung dili sa imo na Session Beans.
If you notice naay property ang Customer nga "id". Mao ni ang ID column mismo sa imo database nga naka-auto-increment (GenerationType.AUTO).
If you notice Customer has a property Address. The annotation maps it in such a way that it has a one-to-one relationship with the ADDRESS table. Automatic na sad ni.
So to use this entity:
/** very simple Session Bean - not ideal to use; for sample purpose lang */
@Stateless
public class CustomerBean implements CustomerRemote {
@PersistenceContext
private EntityManager em;
private Customer customer;
private Address address;
public void newCustomer(String firstName, String lastName, Address address) {
customer = new Customer();
customer.setFirstName(firstName);
customer.setLastName(lastName);
customer.setAddress(address);
em.persist(customer);
}
public void deleteCustomer(Customer customer) {
em.remove(customer.getId);
}
}
That's it! Executing the methods above would insert and delete a Customer object to your database.
"em.persist(customer)" - inserts a row to your CUSTOMER table with an unique ID. This also inserts a row in your ADDRESS table in the database with a unique ID mapped to its corresponding Customer.
"em.remove(customer)" - deletes a row in the CUSTOMER table that has the ID = customer.getId
These are just one of the very basic features available in Java EE 5. Sauna, with J2EE doing this will take much longer because wala pay gamit nga annotations and you have to make deployment descriptors in XML.
Hope this helps.