Bonjour ,

Je developpe un projet de gestion de tests et j'ai 4 questions dans la base de donnée. Lorsque je veut extraire les questions je reçoit une liste avec 15 éléments avec des doublons.
voici la liste reçus :

1, Java est un language
1, Java est un language
1, Java est un language
2, Java est un langage développé par
2, Java est un langage développé par
2, Java est un langage développé par
2, Java est un langage développé par
3, Choisir la bonne réponse
3, Choisir la bonne réponse
3, Choisir la bonne réponse
3, Choisir la bonne réponse
4, La liaison tardive est essentielle pour assurer
4, La liaison tardive est essentielle pour assurer
4, La liaison tardive est essentielle pour assurer
4, La liaison tardive est essentielle pour assurer


J'ai le mapping suivant entre un test et les questions
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
public class Test{
       	private List<Question> questions;
....
	@OneToMany(mappedBy="test",fetch=FetchType.EAGER)
	@Cascade( { org.hibernate.annotations.CascadeType.ALL })
	public Collection<Question> getQuestions() {
		return questions;
	}
	public void setQuestions(List<Question> questions) {
		this.questions = questions;
        }
 
public class Question{
	private Test test;
....
	@ManyToOne
	@JoinColumn(name="test_id")
	public Test getTest() {
		return test;
	}
 
	public void setTest(Test test) {
		this.test = test;
	}
}
J'utilise la fonction dao suivante que j'hérite avec TestDao:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
@Transactional(propagation = Propagation.SUPPORTS)
public class BaseDaoHibernate<T> extends HibernateDAO implements IDao<T> {
	private Class<T> type;
.....
	@SuppressWarnings("unchecked")
	public T findById(Serializable _id) {
 
		T o = (T) this.getHibernateTemplate().get(type, _id);
		return o;
	}
}
Dans le service de test j'ai la classe qui génère l'output:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
public Test getById(int id) {
		// TODO Auto-generated method stub
		Test test = testDao.findById(id);
		System.out.println("TestServiceImpl >> questions.size: "+test.getQuestions().size());
		for(Question q: test.getQuestions())
			System.out.println(q.getId()+", "+q.getLibelle());
		return test;
	}
Voici le log généré par log4j:
support.AbstractBeanFactory>> 13:54:50,546 DEBUG DefaultListableBeanFactory:245 - Returning cached instance of singleton bean 'transactionManager'
support.AbstractPlatformTransactionManager>> 13:54:50,546 DEBUG HibernateTransactionManager:365 - Creating new transaction with name [com.businessdecision.tact.bdtechtest.services.Impl.TestServiceImpl.getById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
hibernate3.HibernateTransactionManager>> 13:54:50,546 DEBUG HibernateTransactionManager:493 - Opened new Session [org.hibernate.impl.SessionImpl@24389c] for Hibernate transaction
hibernate3.HibernateTransactionManager>> 13:54:50,546 DEBUG HibernateTransactionManager:504 - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@24389c]
datasource.DataSourceUtils>> 13:54:50,546 DEBUG DataSourceUtils:110 - Fetching JDBC Connection from DataSource
hibernate3.HibernateTransactionManager>> 13:54:50,562 DEBUG HibernateTransactionManager:569 - Exposing Hibernate transaction as JDBC transaction [Transaction-aware proxy for target Connection [com.mysql.jdbc.JDBC4Connection@189b9bd]]
support.TransactionSynchronizationManager>> 13:54:50,562 DEBUG TransactionSynchronizationManager:193 - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@12f0ce9] for key [org.springframework.jdbc.datasource.SingleConnectionDataSource@f8f104] to thread [http-8080-1]
support.TransactionSynchronizationManager>> 13:54:50,562 DEBUG TransactionSynchronizationManager:193 - Bound value [org.springframework.orm.hibernate3.SessionHolder@1f8a4fd] for key [org.hibernate.impl.SessionFactoryImpl@87286] to thread [http-8080-1]
support.TransactionSynchronizationManager>> 13:54:50,562 DEBUG TransactionSynchronizationManager:272 - Initializing transaction synchronization
interceptor.TransactionAspectSupport>> 13:54:50,562 DEBUG TransactionInterceptor:362 - Getting transaction for [com.businessdecision.tact.bdtechtest.services.Impl.TestServiceImpl.getById]
interceptor.AbstractFallbackTransactionAttributeSource>> 13:54:50,578 DEBUG AnnotationTransactionAttributeSource:106 - Adding transactional method 'getById' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
interceptor.TransactionAspectSupport>> 13:54:50,578 DEBUG AnnotationTransactionAspect:339 - Skipping transactional joinpoint [com.businessdecision.tact.bdtechtest.services.Impl.TestServiceImpl.getById] because no transaction manager has been configured
interceptor.TransactionAspectSupport>> 13:54:50,578 DEBUG AnnotationTransactionAspect:362 - Getting transaction for [com.businessdecision.tact.bdtechtest.services.Impl.TestServiceImpl.getById]
support.AbstractBeanFactory>> 13:54:50,578 DEBUG DefaultListableBeanFactory:245 - Returning cached instance of singleton bean 'transactionManager'
support.TransactionSynchronizationManager>> 13:54:50,578 DEBUG TransactionSynchronizationManager:140 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@1f8a4fd] for key [org.hibernate.impl.SessionFactoryImpl@87286] bound to thread [http-8080-1]
hibernate3.HibernateTransactionManager>> 13:54:50,578 DEBUG HibernateTransactionManager:437 - Found thread-bound Session [org.hibernate.impl.SessionImpl@24389c] for Hibernate transaction
support.TransactionSynchronizationManager>> 13:54:50,578 DEBUG TransactionSynchronizationManager:140 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@12f0ce9] for key [org.springframework.jdbc.datasource.SingleConnectionDataSource@f8f104] bound to thread [http-8080-1]
support.AbstractPlatformTransactionManager>> 13:54:50,578 DEBUG HibernateTransactionManager:470 - Participating in existing transaction
interceptor.TransactionAspectSupport>> 13:54:50,578 DEBUG TransactionInterceptor:362 - Getting transaction for [com.businessdecision.tact.bdtechtest.dao.Utils.BaseDaoHibernate.findById]
interceptor.AbstractFallbackTransactionAttributeSource>> 13:54:50,593 DEBUG AnnotationTransactionAttributeSource:106 - Adding transactional method 'findById' with attribute: PROPAGATION_SUPPORTS,ISOLATION_DEFAULT; ''
interceptor.TransactionAspectSupport>> 13:54:50,593 DEBUG AnnotationTransactionAspect:339 - Skipping transactional joinpoint [com.businessdecision.tact.bdtechtest.dao.Utils.BaseDaoHibernate.findById] because no transaction manager has been configured
interceptor.TransactionAspectSupport>> 13:54:50,593 DEBUG AnnotationTransactionAspect:362 - Getting transaction for [com.businessdecision.tact.bdtechtest.dao.Utils.BaseDaoHibernate.findById]
support.TransactionSynchronizationManager>> 13:54:50,593 DEBUG TransactionSynchronizationManager:140 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@1f8a4fd] for key [org.hibernate.impl.SessionFactoryImpl@87286] bound to thread [http-8080-1]
support.TransactionSynchronizationManager>> 13:54:50,593 DEBUG TransactionSynchronizationManager:140 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@1f8a4fd] for key [org.hibernate.impl.SessionFactoryImpl@87286] bound to thread [http-8080-1]
hibernate3.HibernateTemplate>> 13:54:50,593 DEBUG HibernateTemplate:397 - Found thread-bound Session for HibernateTemplate
Hibernate: select test0_.test_id as test1_1_4_, test0_.duree as duree1_4_, test0_.niveau as niveau1_4_, test0_.nombre as nombre1_4_, test0_.id_technologie as id5_1_4_, test0_.utilisateur_id as utilisat6_1_4_, questions1_.test_id as test4_1_6_, questions1_.id as id6_, questions1_.id as id2_0_, questions1_.libelle as libelle2_0_, questions1_.niveau as niveau2_0_, questions1_.test_id as test4_2_0_, reponses2_.id_Question as id4_2_7_, reponses2_.id as id7_, reponses2_.id as id5_1_, reponses2_.etat as etat5_1_, reponses2_.libelle as libelle5_1_, reponses2_.id_Question as id4_5_1_, technologi3_.id as id3_2_, technologi3_.libelle as libelle3_2_, utilisateu4_.id as id6_3_, utilisateu4_.email as email6_3_, utilisateu4_.hashed as hashed6_3_, utilisateu4_.login as login6_3_, utilisateu4_.mot_de_passe as mot5_6_3_, utilisateu4_.nom as nom6_3_, utilisateu4_.prenom as prenom6_3_, utilisateu4_.salt as salt6_3_, utilisateu4_.type as type6_3_ from Test test0_ left outer join Question questions1_ on test0_.test_id=questions1_.test_id left outer join Reponse reponses2_ on questions1_.id=reponses2_.id_Question left outer join Technologie technologi3_ on test0_.id_technologie=technologi3_.id left outer join Utilisateur utilisateu4_ on test0_.utilisateur_id=utilisateu4_.id where test0_.test_id=?
support.TransactionSynchronizationManager>> 13:54:50,593 DEBUG TransactionSynchronizationManager:140 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@12f0ce9] for key [org.springframework.jdbc.datasource.SingleConnectionDataSource@f8f104] bound to thread [http-8080-1]
hibernate3.HibernateTemplate>> 13:54:50,609 DEBUG HibernateTemplate:422 - Not closing pre-bound Hibernate Session after HibernateTemplate
interceptor.TransactionAspectSupport>> 13:54:50,609 DEBUG TransactionInterceptor:391 - Completing transaction for [com.businessdecision.tact.bdtechtest.dao.Utils.BaseDaoHibernate.findById]
TestServiceImpl >> questions.size: 15
Je ne comprend pas d'ou vient le problème,

Merci d'avance pour votre aide.