Lecture 3A Flashcards
JSP XML syntax possible in JSP 2.x Benefits?
Conforms with XHTML, XML validation against schema, can use XML tools. However, verbose.
What are JSP directives?
They don’t produce output into current output stream. use them to add imports, include or taglib.
What are JSP actions?
Tell web container what to do as opposed to directives which give new information. Fuzzy difference. Use directive only if included file changes rarely, use action which guarantees latest content.
How to forward JSP?
Use forward action-
What are JSP implicit objects?
Available without declaring - provided by EE web container. ie request, response, session, out
JSTL?
JSP Standard Tag Library.
What does JPA stand for?
Java Persistence API. Application Programming Interface. Used for storing and retrieving objects to/from relational database. It provides ORM - maps Java classes to database tables. Javax.persistence
What is a Java process?
A Java program which is currently running.
JPA is a specification. Hibernate is an implementation of that specification.
Hibernate made by RedHat.
JDBC?
Java Database Connectivity. Non enterprise standard java framework. Allows SQL queries into Java code.
JPA entity classes vs entities?
Entity class annotated with @Entity. An entity is an instance of such a class. As an entity a Java object can be stored as a database.
What is a POJO?
Plain Old Java Object. Items stored in db rows using JPA are POJO’s (minus methods).
Entity classes need what to work?
@entity, import javax.persistence.Entity, a public or protected no argument constructor, no Finals, must be serializable sometimes, persistence instance variables (non static fields) must be private, protected or package private.
List some common JPA annotations
@Id @Table @Column
What is the JPA entity manager?
Responsible for storing retrieving Java objects in database. @PersistenceUnit(unitName=”customerPersistenceUnit”) private EntityManagerDactory entityManagerFactory;
EntityManager entityManager = entityManagerFactory.createEntityManager();
What is a persistence context?
The set of Java objects which are controlled by an entity manager instance. It is also a session, the time period during which an entity manager manages these objects.
What is JSP declaration?
Used to define variable / method that gets inserted into main body.
What is the persistent identity?
The primary of an object. Only one entity with a certain persistent identity in the PC.
List some entity manager methods:
Persist(), remove(), refresh(), merge(), createQuery() - using JPQL, flush() - force sync to db
Difference between remove() and detach()
A removed entity is marked for removal from database but not from PC. Detached has A Persistent identity no longer associated with a persistence context.
What happens when close() method called on an entityManager?
Detached all managed entities from PC
What is a transaction?
Calls of entityManager methods must be embedded in a transaction (apart from find()). It’s a set of operations that either fail or succeed as a unit. @Resource UserTransaction object using dependency injection.
Open and close transaction:
@Resource
UserTransaction userTransaction;
UserTransaction.begin();
UserTransaction.commit();