Bonjour,
je debute en java;
je veux recuperer des informations en base et les retourner dans un objet afin qu'il soit utiliser ailleurs;
mais lorsque j'appelle ma fonction, elle ne retourne aucun resultat et pourtant quand je fais un system.out.println, je vois bien les resultats s'afficher
voici mon code:
j'appelle ma fonction:
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 public class testcomp { public String afficherBoutiques () throws HibernateException { String iti = "Bonjour"; Session session = HibernateUtil.currentSession(); List list = session.find("from Boutiques"); Iterator it = list.iterator(); while(it.hasNext()) { Boutiques Boutik = (Boutiques)it.next(); //System.out.println(Boutik.getURLWSBoutik()); iti= Boutik.getURLWSBoutik(); } return iti; }
quand je compile,la console me renvoie ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 public class Tests { public static void main(String[] args) throws HibernateException { testcomp monTest = new testcomp(); monTest.afficherBoutiques(); } }
mon fichier hibernate.cfg.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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit> INFO: Hibernate 2.1.6 18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found 18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer 18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml 18 avr. 2010 06:16:12 net.sf.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration addResource INFO: Mapping resource: Boutiques.hbm 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Binder bindRootClass INFO: Mapping class: com.yohan.hibernate.Boutiques -> boutiques 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-many association mappings 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing one-to-one association property references 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints 18 avr. 2010 06:16:13 net.sf.hibernate.dialect.Dialect <init> INFO: Using dialect: net.sf.hibernate.dialect.MySQLDialect 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Maximim outer join fetch depth: 2 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use outer join fetching: true 18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) 18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/bdcomparateur 18 avr. 2010 06:16:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=root, password=} 18 avr. 2010 06:16:13 net.sf.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory 18 avr. 2010 06:16:13 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use scrollable result sets: true 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Use JDBC3 getGeneratedKeys(): true 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: false 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.SettingsFactory buildSettings INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider 18 avr. 2010 06:16:13 net.sf.hibernate.cfg.Configuration configureCaches INFO: instantiating and configuring caches 18 avr. 2010 06:16:14 net.sf.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 18 avr. 2010 06:16:14 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured
avec aucun resultat.
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
27
28
29
30
31
32
33
34 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"> <hibernate-configuration> <session-factory > <!-- local connection properties --> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/bdcomparateur</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password"></property> <!-- property name="hibernate.connection.pool_size"></property --> <!-- dialect for MySQL --> <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">false</property> <property name="hibernate.use_outer_join">true</property> <!-- <property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property> <property name="jta.UserTransaction">java:comp/UserTransaction</property> --> <property name="hibernate.transaction.factory_class"> net.sf.hibernate.transaction.JDBCTransactionFactory </property> <mapping resource="Boutiques.hbm" /> </session-factory> </hibernate-configuration>
pouvez vous m'aider svp? merci.
Partager