본문 바로가기

Java

[펌]Java Persistence API(JPA)

 [출처] [ JAVA 심화 ] 63. Java Persistence API(JPA)에 관해서|작성자 안경잡이 개발자

         http://blog.naver.com/ndb796/220641056988



JPA(Java Persistence API)는 관계형 데이터베이스에 접근하기 위한 표준 ORM 기술을 제공하며, 기존에 EJB에서 제공되던 엔터티 빈(Entity Bean)을 대체하는 기술입니다. JPA는 JSR 220에서 정의된 EJB 3.0 스펙의 일부로 정의가 되어있습니다. 그렇지만 JPA는 EJB 컨테이너에 의존하지 않고 EJB, 웹 모듈 및 Java SE 클라이언트에서 모두 사용이 가능합니다. 또한 JPA는 사용자가 원하는 퍼시스턴스 프로바이더 구현체를 선택해서 사용할 수 있습니다.

 

Java Persistence API(JPA)가 제공하는 기본적인 특징

 

● Entity Class가 무엇이고 무슨 역할을 하는지 설명하세요.

( What is an Entity class and what it plays? )

 

개체 클래스는 일종의 자바 클래스입니다. 다만 개체 클래스(Entity Class)는 데이터베이스

테이블이 가지는 속성들에 대한 정보를 저장하기 위해서 사용됩니다. 웹 애플리케이션에서

데이터베이스에 접근해서 가져온 데이터를 저장해 그것을 응용할 수 있게 해줍니다.

 

The Entity Class is a kind of Java class. But this Entity Class is used to store some

data from a database table's attribute. In web application, Entity Class can provide

these data brought from database table connecting with web application for applying.

 

● JPA의 Entity는 어떻게 관리할 수 있나요?

( How to manage entities in Java Persistence API? )

 

JPA에서 Entity는 EntityManager 인터페이스를 이용해서 관리할 수 있습니다. 이 EntityManager는

하나의 개체 객체(Entity Instance)를 생성하고 지우고 관리할 수 있도록 다양한 기능을 제공합니다.

 

Developers can manage some Entities by using EntityManager interface in JPA. This

EntityManager can provide a function that help creating, deleting and managing a Entity instance.

 

● Java Persistence Query Language의 목표는 무엇인가요?

( What are the goals of Java Persistence Query Language? )

 

특정 데이터베이스에 국한되지 않고 효율적으로 데이터베이스에 접근해서 SQL문을 실행할 수

있게 해주는 것입니다.

 

The JPQL's goal is helping users to execute SQL statements efficiently

not limited to a specific Database system.

 

● JPQL의 구성요소와 JPQL의 장점과 단점에 대해서 설명하세요.

( What does it consist of and what are pros and cons of using it? )

 

JPQL는 데이터베이스의 개체에 접근할 수 있는 이해하기 쉬운 SQL 기능으로 구성되어있습니다.

SQL과 문법이 비슷해 사용하기 쉽습니다. 또한 특정 데이터베이스에 국한되지 않습니다. 하지만

반드시 SQL문에 별칭(AS)를 붙여야하고 상대적으로 처리 속도가 느리다는 단점이 있습니다.

 

JPQL consist of many SQL functions that are easy to understand and connected with

Database Entities. And the JPQL is easy to use because JPQL is similar to general SQL.

JPQL is also not limited to a specific Database system. However for using JPQL, developers

must add Alias(AS) to SQL statements and the JPQL processing speed is relatively slow.

 

● JPQL의 예시를 보여주세요.

(Give some simple examples of Java Persistence Language Queries. )

 

String jpql = "SELECT C FROM Customer as C WHERE C.CustomerName = "Jiho";

List <Customer> result = em.createQuery(jpql, Customer.class).getResultList();


'Java' 카테고리의 다른 글

Generic  (0) 2016.03.08
Reflection API  (0) 2016.03.08
Collection API  (0) 2016.03.08
Excel download & upload  (1) 2016.03.03
[error] The type BASE64Decoder is not accessible due to restriction on required library  (0) 2016.01.11