Bonjour
J'ai un souci
Ben voila j'ai une table dont le contenu du fichier.hbm.xml est :
-------> la classe EntrepriseDec.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="com.tva.bo"> <class name="com.tva.bo.EntrepriseDec" table="entreprise_dec" proxy="com.tva.bo.EntrepriseDec" lazy="true" > <id name="identifiant" column="identifiant" type="java.lang.Integer"> <generator class="sequence"> <param name="sequence">seq_entreprise_dec</param> </generator> </id> <property name="ninea" column="ninea"/> <property name="date_declaration" column="date_declaration"/> <property name="agent_autorise" column="agent_autorise"/> <property name="penalite_du" column="penalite_du"/> <property name="interet_du" column="interet_du"/> <property name="total_du" column="total_du"/> <property name="date" column="date"/> <property name="noms_complets" column="noms_complets"/> <property name="titre" column="titre"/> <property name="telephone" column="telephone"/> <set name="declarations" inverse="true" cascade="all-delete-orphan"> <key column="identifiant"/> <one-to-many class="com.tva.bo.Declaration"/> </set> <many-to-one name="entreprise" unique="true" outer-join="true" insert="false" update="false" lazy="true" not-found="ignore" class="com.tva.bo.Entreprise"> <column name="ninea"/> </many-to-one> </class> </hibernate-mapping>
ma methode qui me permet de faire un select dans le dao:
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211 package com.tva.bo; import java.io.Serializable; import java.util.Date; import java.util.HashSet; import java.util.Set; public class EntrepriseDec implements Serializable { private int identifiant ; private String ninea ; private Date date_declaration ; private String agent_autorise; private double penalite_du ; private double interet_du ; private double total_du ; private Date date; private String noms_complets; private String titre; private String telephone; private Entreprise entreprise; private Set declarations = new HashSet(); public void addDeclarations(Declaration d) { d.setEntrepriseDec(this); declarations.add(d); } public EntrepriseDec() { this.identifiant= 0 ; this.ninea=""; this.date_declaration=new Date(); this.agent_autorise=""; this.penalite_du= 0 ; this.interet_du = 0 ; this.total_du = 0 ; this.date=new Date(); this.noms_complets=""; this.titre=""; this.telephone=""; this.entreprise = new Entreprise(); } /** * @return Returns the agent_autorise. */ public String getAgent_autorise() { return agent_autorise; } /** * @param agent_autorise The agent_autorise to set. */ public void setAgent_autorise(String agent_autorise) { this.agent_autorise = agent_autorise; } /** * @return Returns the date. */ public Date getDate() { return date; } /** * @param date The date to set. */ public void setDate(Date date) { this.date = date; } /** * @return Returns the date_declaration. */ public Date getDate_declaration() { return date_declaration; } /** * @param date_declaration The date_declaration to set. */ public void setDate_declaration(Date date_declaration) { this.date_declaration = date_declaration; } /** * @return Returns the entreprise. */ public Entreprise getEntreprise() { return entreprise; } /** * @param entreprise The entreprise to set. */ public void setEntreprise(Entreprise entreprise) { this.entreprise = entreprise; } /** * @return Returns the identifiant. */ public int getIdentifiant() { return identifiant; } /** * @param identifiant The identifiant to set. */ public void setIdentifiant(int identifiant) { this.identifiant = identifiant; } /** * @return Returns the interet_du. */ public double getInteret_du() { return interet_du; } /** * @param interet_du The interet_du to set. */ public void setInteret_du(double interet_du) { this.interet_du = interet_du; } /** * @return Returns the ninea. */ public String getNinea() { return ninea; } /** * @param ninea The ninea to set. */ public void setNinea(String ninea) { this.ninea = ninea; } /** * @return Returns the noms_complets. */ public String getNoms_complets() { return noms_complets; } /** * @param noms_complets The noms_complets to set. */ public void setNoms_complets(String noms_complets) { this.noms_complets = noms_complets; } /** * @return Returns the penalite_du. */ public double getPenalite_du() { return penalite_du; } /** * @param penalite_du The penalite_du to set. */ public void setPenalite_du(double penalite_du) { this.penalite_du = penalite_du; } /** * @return Returns the telephone. */ public String getTelephone() { return telephone; } /** * @param telephone The telephone to set. */ public void setTelephone(String telephone) { this.telephone = telephone; } /** * @return Returns the titre. */ public String getTitre() { return titre; } /** * @param titre The titre to set. */ public void setTitre(String titre) { this.titre = titre; } /** * @return Returns the total_du. */ public double getTotal_du() { return total_du; } /** * @param total_du The total_du to set. */ public void setTotal_du(double total_du) { this.total_du = total_du; } /** * @return Returns the declarations. */ public Set getDeclarations() { return declarations; } /** * @param declarations The declarations to set. */ public void setDeclarations(Set declarations) { this.declarations = declarations; } }
et le probleme que j'ai
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 public int getIdMaxEntrepriseDec() { logger.info("Entree dans la methode getIdMaxEntrepriseDec la classe DeclarationDao"); Session session = this.getSessionFactory().openSession(); //Declaration declaration= new Declaration(); List list =new ArrayList(); String resultat=""; Integer valeur = new Integer(0); try{ Transaction tx = session.beginTransaction(); //valeur = (Integer)session.createSQLQuery(" select max(entrepriseDec.identifiant)as max from EntrepriseDec entrepriseDec ").addScalar("max",Hibernate.INTEGER ).uniqueResult(); list=session.createSQLQuery(" select max(entrepriseDec.identifiant)as max from EntrepriseDec entrepriseDec ").addScalar("max",Hibernate.INTEGER).list(); if (list != null && list.size() > 0) { if (list.get(0) != null) { valeur = (Integer) list.get(0); } } tx.commit(); }catch (Exception e){ e.printStackTrace(); logger.error("Erreur lors de la recuperation du max de l'identifiant"); }finally{ session.close(); } return (valeur.intValue()) ; }
Lorsque je fais une insertion ça marche
mais lorsque je veux faire un select ça me donne un message 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
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 Hibernate: select max(entrepriseDec.identifiant)as max from EntrepriseDec entrepriseDec WARN : JDBCExceptionReporter.java -> SQL Error: 0, SQLState: 42P01 ERROR : JDBCExceptionReporter.java -> ERROR: relation "entreprisedec" does not exist org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153) at com.tva.dao.imp.EntrepriseDecDao.getIdMaxEntrepriseDec(EntrepriseDecDao.java:147) at com.tva.manager.imp.EntrepriseDecMg.getIdMaxEntrepriseDec(EntrepriseDecMg.java:68) at com.tva.struts.action.declaration.EnregistrerDeclarationAction.executeAction(EnregistrerDeclarationAction.java:254) at com.tva.struts.action.ActionBase.execute(ActionBase.java:155) at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at com.tva.struts.servlets.ServletBase.doPost(ServletBase.java:38) at javax.servlet.http.HttpServlet.service(HttpServlet.java:709) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Caused by: java.sql.SQLException: ERROR: relation "entreprisedec" does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1501) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1283) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:186) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:392) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:330) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:240) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120) at org.hibernate.loader.Loader.getResultSet(Loader.java:1272) at org.hibernate.loader.Loader.doQuery(Loader.java:391) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) ... 30 more
QUELQU'UN PEUT M'AIDER SVP je suis bloquée la dessus ?
Partager