Bonjour j'ai un petit soucis lors d'une mise à jour de données je m'explique, je dispose d'une classe Rebut qui représente des rejets sur une ligne de production :
Cette classe est mappée pour être persistée via hibernate dans une base SQL Server voici le mapping :
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 public class Rebut implements Serializable{ private static final long serialVersionUID = -662108058222368049L; private RebutItem rebut; private Produit produit; private ProductionLine ligne; private Date date; private String poste; private int quantite; private int quantiteReintegree; private int quantiteFinale; private int semaine; private int mois; private int annee; private String ordre; private String operation; private String code_rebut; private String code_ligne; public String getCode_ligne() { return code_ligne; } public void setCode_ligne(String code_ligne) { this.code_ligne = code_ligne; } public String getCode_rebut() { return code_rebut; } public void setCode_rebut(String code_rebut) { this.code_rebut = code_rebut; } public String getOperation() { return operation; } public void setOperation(String operation) { this.operation = operation; } public String getOrdre() { return ordre; } public void setOrdre(String ordre) { this.ordre = ordre; } public int getAnnee() { return annee; } public void setAnnee(int annee) { this.annee = annee; } public int getMois() { return mois; } public void setMois(int mois) { this.mois = mois; } public int getSemaine() { return semaine; } public void setSemaine(int semaine) { this.semaine = semaine; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public ProductionLine getLigne() { return ligne; } public void setLigne(ProductionLine ligne) { this.ligne = ligne; } public String getPoste() { return poste; } public void setPoste(String poste) { this.poste = poste; } public int getQuantite() { return quantite; } public void setQuantite(int quantite) { this.quantite = quantite; } public RebutItem getRebut() { return rebut; } public void setRebut(RebutItem rebut) { this.rebut = rebut; } public Produit getProduit() { return produit; } public void setProduit(Produit produit) { this.produit = produit; } public int getQuantiteFinale() { return quantiteFinale; } public void setQuantiteFinale(int quantiteFinale) { this.quantiteFinale = quantiteFinale; } public int getQuantiteReintegree() { return quantiteReintegree; } public void setQuantiteReintegree(int quantiteReintegree) { this.quantiteReintegree = quantiteReintegree; } }
lorsque j'utilise l'entité "Rebut" pour effectuer des select, aucun problème par contre dès que je tente de faire une insertion en utilisant l'entitée "RebutUpdate" j'ai une exception
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 <hibernate-mapping> <class name="javabeans.production.Rebut" table="E_DECLARATION_QUANTITE" entity-name="Rebut"> <composite-id> <key-property name="date" type="date" column="DATE_CALENDRIER" /> <key-property name="poste" column="CODE_EQUIPE" /> <key-many-to-one name="produit" class="javabeans.production.Produit"> <column name="NUMERO_ORDRE"/> <column name="NUMERO_OPERATION"/> </key-many-to-one> <key-many-to-one name="rebut" class="javabeans.production.RebutItem" column="CODE_REBUT"/> <key-many-to-one name="ligne" class="javabeans.production.ProductionLine" column="CODE_POSTE"/> </composite-id> <property name="quantite" column="QUANTITE"/> <property name="semaine" type="integer"> <formula>dbo.SemaineIso(DATE_CALENDRIER)</formula> </property> <property name="annee" type="integer"> <formula>year(DATE_CALENDRIER)</formula> </property> <property name="mois" type="integer"> <formula>month(DATE_CALENDRIER)</formula> </property> </class> <class name="javabeans.production.Rebut" table="E_DECLARATION_QUANTITE" entity-name="RebutUpdate"> <composite-id> <key-property name="date" type="date" column="DATE_CALENDRIER" /> <key-property name="poste" column="CODE_EQUIPE" /> <key-property name="ordre" column="NUMERO_ORDRE"/> <key-property name="operation" column="NUMERO_OPERATION"/> <key-property name="code_rebut" column="CODE_REBUT"/> <key-property name="code_ligne" column="CODE_POSTE"/> </composite-id> <property name="quantite" column="QUANTITE"/> </class> </hibernate-mapping>
voila le code de l'insertion :org.hibernate.MappingException: Unknown entity: RebutUpdate
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1089)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:409)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:82)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at dao.hibernate.production.HibernateRebutDAO.saveRebut(HibernateRebutDAO.java:158)
at actions.production.RebutSaisieDispatchAction.save(RebutSaisieDispatchAction.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
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:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
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 net.sf.jguard.authentication.http.AccessFilter.authorize(AccessFilter.java:672)
at net.sf.jguard.authentication.http.AccessFilter.doFilter(AccessFilter.java:436)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
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:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)
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)
Si vous avez une piste de réponse je suis preneur merci d'avance
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 public void saveRebut(Rebut r){ Session session = HibernateSessionFactory.currentSession(); try{ Transaction tx = session.beginTransaction(); session.saveOrUpdate("RebutUpdate",r); tx.commit(); } catch(Exception e){ e.printStackTrace(); } finally{ try{ HibernateSessionFactory.closeSession(); } catch(Exception e1){ e1.printStackTrace(); } } }![]()
Partager