Bonjour,
Je débute avec JPA et je n'arrive pas à résoudre l'erreur suivante :
Apparemment, "Customer" et "Address" ne sont pas référencés.
Ma classe bank
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Exception in thread "main" Local Exception Stack: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@22a316ad Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [bankPersistenceUnit] failed. Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.ValidationException Exception Description: [class ch.hearc.ig.bank.business.Bank] uses a non-entity [class ch.hearc.ig.bank.business.Customer] as target entity in the relationship attribute [field customers]. at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) at ch.hearc.ig.bank.service.JpaBank.researchAddress(JpaBank.java:23) at ch.hearc.ig.bank.application.Application.main(Application.java:22)
Mon fichier xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 @Entity @Table(name="BANQUE") public class Bank implements Serializable{ @Id @Column(name="NUMERO") private Integer number; @Column(name="NOM") private String name; @ManyToOne @JoinColumn(name="ADRESSE_NUMERO") private Address address; @OneToMany private List<Customer> customers;
Pouvez-vous m'aider ? Merci
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 <?xml version="1.0" encoding="UTF-8" ?> <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_2_0.xsd" version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="employesPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <class>ch.hearc.ig.bank.business.Customer</class> <properties> privé </properties> </persistence-unit> <persistence-unit name="addressPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <class>ch.hearc.ig.bank.business.Address</class> <properties> privé </properties> </persistence-unit> <persistence-unit name="bankPersistenceUnit" transaction-type="RESOURCE_LOCAL"> <class>ch.hearc.ig.bank.business.Bank</class> <properties> privé </properties> </persistence-unit> </persistence>
Partager