Bonsoir à tous,
J'ai un problème de persistance lorsque je fais mes tests unitaires :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 java.lang.IllegalArgumentException: Unknown entity: com.model.remote.entities.Model at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:193) at org.ow2.easybeans.persistence.TxEntityManager.find(TxEntityManager.java:114)...... Caused by: org.hibernate.MappingException: Unknown entity: com.model.remote.entities.Model
J'ai mon EJB "ModelServiceBean"
mon persistance.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
15
16
17 package com.model.ejb.v1; public class ModelServiceBean implements ModelServiceSEI { private static final HWLogger logger = new HWLogger(ModelServiceBean.class); @PersistenceContext(unitName = "hw.model.pu") private EntityManager manager; @Resource(mappedName = "hwDS") private DataSource datasource; @EJB private SearchServiceLocal searchService; etc....
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 <?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="hw.model.pu" transaction-type="JTA"> <jta-data-source>hwDS</jta-data-source> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.show_sql" value="false" /> <property name="hibernate.format_sql" value="true" /> <property name="hibernate.cache.use_second_level_cache" value="true" /> <property name="hibernate.cache.use_query_cache" value="false" /> <property name="hibernate.cache.provider_configuration_file_resource_path" value="ehcache.xml" /> <property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" /> <property name="net.sf.ehcache.configurationResourceName" value="/com/model/cache/ehcache.xml" /> </properties> </persistence-unit> </persistence>
Et mon fichier Model.java
Certes, mon "entitie" Model n'est pas dans le même projet que mon EJB, mais il est inclus dans mon classpath et à la compilation, j'ai n'ai pas d'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package com.model.remote.entities; @Entity @Table(name = "T_MODEL") public class Model { @Id @GeneratedValue(generator = "InvSeq") @SequenceGenerator(name = "InvSeq", sequenceName = "T_MODEL_ID_SEQ", allocationSize = 5) @Column(name = "ID_MODEL") protected Long id; @Column(name = "T_M_ID_MODEL") protected Long idParent;
C'est plus lorsque je tomber sur un testUnitaire, il plante sur ce type de méthode, lors d'un find :
Si quelqu'un peut m'eclairer, merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 @TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED) @Interceptors(CheckerOnModel.class) public ItemModel getModel(String sc, Long id, Long version) throws HWException { ItemModel itemModel = new ItemModel(); Model model = null; try { model = manager.find(Model.class, id);![]()
Partager