Salut a tous,
j'ai crée avec l'aide de l'assistant de netbeans 6.5 une entity langue et un bean façade langueFacade pour exploiter cette entity .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="EnterpriseApplicationCatring2-ejbPU" transaction-type="JTA"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>postgresql</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="hibernate.hbm2ddl.auto" value="update"/> </properties> </persistence-unit> </persistence> </application-client>Lorsque j'essaie d'utiliser la langueFacade glassfish lance l'exception nullpointerexception qui est causé par le fait que l'entitymanager est null .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 public class LangueFacade implements LangueFacadeLocal { @PersistenceContext private EntityManager em; public void create(Langue langue) { em.persist(langue); } public void edit(Langue langue) { em.merge(langue); } public void remove(Langue langue) { em.remove(em.merge(langue)); } public Langue find(Object id) { return em.find(Langue.class, id); } public List<Langue> findAll() { return em.createQuery("select object(o) from Langue as o").getResultList(); } }
Que faire ?
Merci d'avance.
Partager