Lecture 3A Flashcards

1
Q

JSP XML syntax possible in JSP 2.x Benefits?

A

Conforms with XHTML, XML validation against schema, can use XML tools. However, verbose.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are JSP directives?

A

They don’t produce output into current output stream. use them to add imports, include or taglib.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are JSP actions?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to forward JSP?

A

Use forward action-

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are JSP implicit objects?

A

Available without declaring - provided by EE web container. ie request, response, session, out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JSTL?

A

JSP Standard Tag Library.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does JPA stand for?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Java process?

A

A Java program which is currently running.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JPA is a specification. Hibernate is an implementation of that specification.

A

Hibernate made by RedHat.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JDBC?

A

Java Database Connectivity. Non enterprise standard java framework. Allows SQL queries into Java code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JPA entity classes vs entities?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a POJO?

A

Plain Old Java Object. Items stored in db rows using JPA are POJO’s (minus methods).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Entity classes need what to work?

A

@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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List some common JPA annotations

A

@Id @Table @Column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the JPA entity manager?

A

Responsible for storing retrieving Java objects in database. @PersistenceUnit(unitName=”customerPersistenceUnit”) private EntityManagerDactory entityManagerFactory;
EntityManager entityManager = entityManagerFactory.createEntityManager();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a persistence context?

A

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.

17
Q

What is JSP declaration?

A

Used to define variable / method that gets inserted into main body.

18
Q

What is the persistent identity?

A

The primary of an object. Only one entity with a certain persistent identity in the PC.

19
Q

List some entity manager methods:

A

Persist(), remove(), refresh(), merge(), createQuery() - using JPQL, flush() - force sync to db

20
Q

Difference between remove() and detach()

A

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.

21
Q

What happens when close() method called on an entityManager?

A

Detached all managed entities from PC

22
Q

What is a transaction?

A

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.

23
Q

Open and close transaction:

A

@Resource
UserTransaction userTransaction;
UserTransaction.begin();
UserTransaction.commit();