2009/2010
Nom, Prénom :
Final JEE
Documents autorisés : Aucun Durée : 1h45.
1)
A quoi correspond le mode AUTOCOMMIT ? Que se passe t-il si on le désactive ? (1 points / 5 minutes)2)
Que signifie l'acronyme CRUD ?(0,5 points / 2 minutes)
3)
Quelle est la fonction d'un Data Access Object (je ne demande pas ici les détails d'implémentation) ?(0,5 points / 2 minutes)
4)
Qu'apporte un framework de persistance type Hibernate par rapport au requétage direct ?(2 points / 5 minutes)
5)
Que représente un “dialecte” dans le framework Hibernate ?(0,25 points / 2 minutes)
6)
A quoi correspond la propriété de configuration d'hibernate hbm2ddl.auto ?(1 points / 5 minutes)
7)
Que se passe t-il si la propriété de configuration hbm2ddl.auto n'est pas renseignée ?(0,5 points / 2 minutes)
8)
Qu'est de qu'un GENERATOR ?(0,5 points / 5 minutes)
9)
Compléter les trous matérialisés par des zones surlignées : DAOFactory :package com.jnesis.model.advert.dao;
import com.jnesis.model.generic.dao.LegalPersonDAO;
public DAOFactory { public ItemDAO getItemDAO();
public RealEstateDAO getRealEstateDAO();
public CityDAO getCityDAO();
public OptionDAO getOptionDAO();
public getHouseDAO();
public AdvertDAO getAdvertDAO();
public LegalPersonDAO getLegalPersonDAO();
}
HibernateDAOFactory :
package com.jnesis.model.advert.hibernate.dao;
import com.jnesis.model.advert.dao.AdvertDAO;
import com.jnesis.model.advert.dao.ItemDAO;
import com.jnesis.model.advert.dao.CityDAO;
import com.jnesis.model.advert.dao.DAOFactory;
import com.jnesis.model.advert.dao.HouseDAO;
import com.jnesis.model.advert.dao.OptionDAO;
import com.jnesis.model.advert.dao.RealEstateDAO;
import com.jnesis.model.generic.dao.LegalPersonDAO;
import com.jnesis.model.generic.hibernate.dao.HibernateLegalPersonDAO;
public class HibernateDAOFactory { public AdvertDAO getAdvertDAO() {
return new HibernateAdvertDAO();
}
public ItemDAO getItemDAO() {
return new HibernateItemDAO();
}
public RealEstateDAO getRealEstateDAO() {
return new HibernateRealEstateDAO();
}
public CityDAO getCityDAO() {
return new HibernateCityDAO();
}
public OptionDAO getOptionDAO() {
return new HibernateOptionDAO();
}
public getHouseDAO() {
return new ();
}
public LegalPersonDAO getLegalPersonDAO() {
return new HibernateLegalPersonDAO();
} }
HouseDAO :
package com.jnesis.model.advert.dao;
import com.jnesis.model.advert.bean.House;
import java.util.List;
public HouseDAO {
public List<House> getList() throws DAOException;
public House getById(Long id) throws DAOException;
public void save(House house) throws DAOException;
public void update(House house) throws DAOException;
public void (House house) throws DAOException;
}
HibernateHouseDAO :
package com.jnesis.model.advert.hibernate.dao;
import com.jnesis.model.advert.bean.House;
import com.jnesis.model.advert.dao.DAOException;
import com.jnesis.model.advert.dao.HouseDAO;
import com.jnesis.model.advert.hibernate.util.HibernateUtil;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
public class HibernateHouseDAO {
public House getById(Long id) throws DAOException {
House house = null;
Session hibernate =
HibernateUtil.getSessionFactory().getCurrentSession();
try {
.beginTransaction();
house = (House) hibernate.get( .class, id);
hibernate.getTransaction(). ; }
catch(HibernateException he) {
if(hibernate.getTransaction() != null) {
hibernate.getTransaction(). ; }
throw new DAOException(he);
}
return house;
}
public void throws DAOException {
Session hibernate =
HibernateUtil.getSessionFactory().getCurrentSession();
try {
.beginTransaction();
hibernate.save(house);
hibernate.getTransaction(). ; }
catch(HibernateException he) {
if(hibernate.getTransaction() != null) {
hibernate.getTransaction(). ; }
throw new DAOException(he);
} }
public void update(House house) throws DAOException {
Session hibernate =
HibernateUtil.getSessionFactory().getCurrentSession();
try {
.beginTransaction();
hibernate. (house);
hibernate.getTransaction(). ; }
catch(HibernateException he) {
if(hibernate.getTransaction() != null) {
hibernate.getTransaction(). ; }
throw new DAOException(he);
} }
public void delete(House house) throws DAOException {
Session hibernate =
HibernateUtil.getSessionFactory().getCurrentSession();
try {
.beginTransaction();
hibernate.delete( );
hibernate.getTransaction(). ; }
catch(HibernateException he) {
if(hibernate.getTransaction() != null) {
hibernate.getTransaction(). ; }
throw new DAOException(he);
} }
public List<House> getList() throws DAOException {
Session hibernate =
HibernateUtil.getSessionFactory().getCurrentSession();
List<House> houseList = null;
try {
.beginTransaction();
houseList = hibernate.createQuery(" ").list();
hibernate.getTransaction(). ; }
catch(HibernateException he) {
if(hibernate.getTransaction() != null) {
hibernate.getTransaction(). ; }
throw new DAOException(he);
}
return houseList;
} }
(4,5 points / 10 minutes)
10)
Ecrivez la requête HQL qui, en fonction dufichier de configuration ci-dessous, permet d'obtenir la liste des villes de plus de 10000 habitants :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.jnesis.model.advert.bean.Ville" table="city">
<id name="id" column="id">
<generator class="native" />
</id>
<property name="name" column="name" />
<property name="zipcode" column="zipcode" />
<property name="nbHabitants" column="nb" />
</class>
</hibernate-mapping>
(3,5 points / 5 minutes)
11)
JPA et hibernate sont-ils 2 frameworksconcurrent ? Expliquez ?
(1,5 points / 5 minutes)
12)
Parmi les applications ci-dessous, lesquellessont techniquement réalisables et pourquoi ?
•
Application avec : Hibernate seul + Oracle + Tomcat•
Application avec : JPA seul + Oracle + Jboss•
Application avec : JPA + Hibernate + Oracle + JBoss•
Application avec : JPA + Hibernate + MySQL + JBoss•
Application avec : JPA + Toplink + My SQL + JBoss•
Application avec : JPA + Hibernate + Toplink + Oracle•
Application avec : JPA + Hibernate + Toplink + Oracle + MySQL(1,75 points / 8 minutes)
13)
Qu'est ce qu'une unité de persistance ?(1 points / 2 minutes)
14)
Au minimum, quelles annotations faut-ilajouter un un Bean pour qu'il puisse être rendu persistant en base de données avec JPA ?
(2 points / 2 minutes)
15)
Qu'est ce que le lazy loading ?(1 points / 2 minutes)
16)
A quoi correspond la méthode persist() d'unl'entity manager JPA?
(2 points / 2 minutes)
17)
Quelle est la procédure à mettre en oeuvrepour mettre à jour en base de données les modification effectuées sur un objet dans l'état “Géré” par le context de persistance ?
(1 points / 1 minute)
18)
Que signifie l'état “Détaché” pour une entitéJPA ?
(0,5 points / 1 minute)
19)
Quels sont les 5 types de relations inter-entités gérées par JPA ?
(1,25 points / 5 minutes)
20)
A quoi correspond l'annotation JPA@JoinColumn ?
(0,5 points / 1 minute)
21)
Qu'est ce qu'une relation bidirectionnelle et àquoi correspond l'attribut JPA MappedBy ?
(2 points / 3 minutes)
22)
En quoi est-ce intéressant d'utiliser le mode decascade CascadeType.PERSIST ?
(3 points / 5 minutes)
23)
A quoi correspond l'annotation@NamedQuery ?
(1 points / 1 minutes)
24)
Comment accède t-on aux méthodes d'un EJBsession ?
(3 points / 10 minutes)
25)
Quels sont les 2 types d'EJB session et en quoisont-ils différents ?
(1,5 points / 5 minutes)
26)
Qu'est ce qu'une application d'entreprise et dequoi est-elle constituée ?
(2,75 points / 5 minutes)