Bonjour,
En relation avec un post que j'ai écrit sur le forum "Persistance", je cherche à faire fonctionner une requête SQL en "dur"... Hélas, je me prends une exception.
Voici la requête SQL, laquelle se veut fort simple :
Directement lancée sous MySQL, elle répond proprement :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 select distinct(ren.JOURNEE) from RENCONTRE ren
Maintenant, en Java :
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 mysql> select distinct(ren.JOURNEE) from RENCONTRE ren; +---------+ | JOURNEE | +---------+ | 0 | | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | | 15 | | 16 | | 17 | | 18 | | 19 | | 20 | | 21 | +---------+ 22 rows in set (0.00 sec)
Son exécution lève une exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 SQLQuery sql = session.createSQLQuery("select distinct(ren.JOURNEE) from RENCONTRE ren"); sql.addEntity("ren", Rencontre.class); List<Integer> l = sql.list();
Quelqu'un pourrait-il me dire ce que j'aurais omis de faire ou mal fait ?
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 Hibernate: select distinct(ren.JOURNEE) from RENCONTRE ren 2 janv. 2011 12:29:11 org.hibernate.util.JDBCExceptionReporter logExceptions ATTENTION: SQL Error: 0, SQLState: S0022 2 janv. 2011 12:29:11 org.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: Column 'OID0_' not found. org.hibernate.exception.GenericJDBCException: could not execute query 2 janv. 2011 12:29:11 org.apache.struts.util.PropertyMessageResources loadLocale ATTENTION: Resource org/apache/struts/action/ActionResources_fr_FR.properties Not Found. 2 janv. 2011 12:29:11 org.apache.struts.util.PropertyMessageResources loadLocale ATTENTION: Resource org/apache/struts/action/ActionResources_fr.properties Not Found. 2 janv. 2011 12:29:11 org.apache.catalina.core.ApplicationContext log GRAVE: action: null java.lang.NullPointerException at metier.plugin.DemarragePlugIn.init(DemarragePlugIn.java:34) at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:884) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:356) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3025) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:432) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1278) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559) at java.lang.Thread.run(Unknown Source) 2 janv. 2011 12:29:11 org.apache.catalina.core.ApplicationContext log INFO: La servlet action est marqué comme indisponible 2 janv. 2011 12:29:11 org.apache.catalina.core.StandardContext loadOnStartup GRAVE: La servlet /Champ7 a généré une exception "load()" javax.servlet.UnavailableException at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:893) at org.apache.struts.action.ActionServlet.init(ActionServlet.java:356) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3025) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:432) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1278) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559) at java.lang.Thread.run(Unknown Source)
Merci par avance.
Partager