· 6 years ago · Aug 09, 2019, 09:00 PM
1@Entity
2public class Client implements Serializable {
3@Id @GeneratedValue
4private long code;
5private String nom;
6private String email;
7@OneToMany(mappedBy = "client",fetch = FetchType.LAZY)
8private Collection<Compte> comptes;
9public Client(long code, String nom, String email, Collection<Compte> comptes) {
10 this.code = code;
11 this.nom = nom;
12 this.email = email;
13 this.comptes = comptes;
14}
15/...
16getters and setters
17}
18
19@Entity
20@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
21@DiscriminatorColumn(name = "TYPE_CPTE,",discriminatorType= DiscriminatorType.STRING,length = 2)
22public abstract class Compte implements Serializable {
23@Id
24private String codeCompte;
25private Date dataCreation;
26private double solde;
27@ManyToOne
28@JoinColumn(name="CODE_CLI")
29private Client client;
30@OneToMany(mappedBy="compte")
31private Collection<Operation> operations;
32
33public Compte() {
34 super();
35}
36
37 public Compte(String codeCompte, Date dataCreation, double solde, Client client, Collection<Operation> operations) {
38 this.codeCompte = codeCompte;
39 this.dataCreation = dataCreation;
40 this.solde = solde;
41 this.client = client;
42 this.operations = operations;
43 }
44
45 /...
46 getters and setters
47 }
48
49@Entity
50 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
51 @DiscriminatorColumn(name = "TYPE_OP",discriminatorType = DiscriminatorType.STRING,length = 1)
52 public abstract class Operation implements Serializable{
53 @Id @GeneratedValue
54 private long numero;
55 private Date dateOperation;
56 private double montant;
57 @ManyToOne
58 @JoinColumn(name = "CODE_CPTE")
59 private Compte compte;
60
61 public Operation() {
62 super();
63 }
64
65 public Operation(Date dateOperation, double montant, Compte compte) {
66 this.dateOperation = dateOperation;
67 this.montant = montant;
68 this.compte = compte;
69 }
70 /...getters and setters
71 }
72
73@Entity
74 @DiscriminatorValue("R")
75 public class Retrait extends Operation {
76 public Retrait() {
77 }
78 public Retrait(Date dateOperation, double montant, Compte compte) {
79 super(dateOperation, montant, compte);
80 }
81 }
82
83@Entity
84 @DiscriminatorValue("V")
85 public class Versement extends Operation {
86 public Versement() {
87 }
88 public Versement(Date dateOperation, double montant, Compte compte) {
89 super(dateOperation, montant, compte);
90 }
91 }
92
93@Entity
94@DiscriminatorValue("CE")
95public class CompteEpargne extends Compte {
96private double taux;
97public CompteEpargne(String s, Date date, int i, Client c2, double taux) {
98 this.taux = taux;
99}
100
101public CompteEpargne(String codeCompte, Date dataCreation, double solde, Client client, Collection<Operation> operations, double taux) {
102 super(codeCompte, dataCreation, solde, client, operations);
103 this.taux = taux;
104}
105public CompteEpargne(){
106 super();
107}
108/...getters and setters
109}
110**entity CompteEpagne**
111
112@Entity
113@DiscriminatorValue("CC")
114public class CompteCourant extends Compte {
115private double decouvert;
116
117public CompteCourant(String s, Date date, int i, Client c1, double decouvert) {
118 this.decouvert = decouvert;
119}
120
121public CompteCourant(String codeCompte, Date dataCreation, double solde, Client client, Collection<Operation> operations, double decouvert) {
122 super(codeCompte, dataCreation, solde, client, operations);
123 this.decouvert = decouvert;
124}
125public CompteCourant(){
126 super();
127}
128/...getters and setters
129}
130
131@Repository
132public interface ClientRep extends JpaRepository<Client,Long> {
133}
134
135@Repository
136public interface CompteRep extends JpaRepository<Compte,String> {
137}
138
139@Repository
140public interface OperationRep extends JpaRepository<Operation,Long> {
141@Query("select o from Operation o where o.compte.codeCompte=:x order by o.dateOperation desc ")
142public Page<Operation> listOperation(String codeCpte, Pageable pageable);
143}
144
145public interface IBankMetier {
146public Compte consulterCompte(String codeCpte);
147public void verser(String codeCpte, double montant);
148public void retirer(String codeCpte, double montant);
149public void virement(String codeCpte1, String codeCpte2, double montant);
150public Page<Operation> listOperation(String codeCpte, int page, int size);
151}
152
153@Service
154@Transactional
155public class BankMetierImp implements IBankMetier {
156@Autowired
157private CompteRep compteRep;
158@Autowired
159private OperationRep operationRep;
160@Override
161public Compte consulterCompte(String codeCpte) {
162 Compte cp = compteRep.findOne(codeCpte);
163 if (cp == null) throw new RuntimeException("Compte introvable");
164 return cp;
165}
166
167@Override
168public void verser(String codeCpte, double montant) {
169 Compte cp = consulterCompte(codeCpte);
170 Versement v = new Versement(new Date(), montant, cp);
171 operationRep.save(v);
172 cp.setSolde((cp.getSolde() + montant));
173 compteRep.save(cp);
174}
175
176@Override
177public void retirer(String codeCpte, double montant) {
178 Compte cp = consulterCompte(codeCpte);
179 double facili = 0;
180 if (cp instanceof CompteCourant)
181 facili = ((CompteCourant) cp).getDecouvert();
182 if (cp.getSolde() + facili < montant)
183 throw new RuntimeException("solde insuffisant");
184 Retrait retrait = new Retrait(new Date(), montant, cp);
185 operationRep.save(retrait);
186 cp.setSolde((cp.getSolde() - montant));
187 compteRep.save(cp);
188}
189
190@Override
191public void virement(String codeCpte1, String codeCpte2, double montant) {
192 retirer(codeCpte1, montant);
193 verser(codeCpte2, montant);
194}
195
196@Override
197public Page<Operation> listOperation(String codeCpte, int page, int size) {
198 return operationRep.listOperation(codeCpte,new PageRequest(page,size));
199}
200}
201
202@SpringBootApplication
203public class MeinproApplication implements CommandLineRunner {
204@Autowired
205private ClientRep clientRep;
206@Autowired
207private CompteRep compteRep;
208@Autowired
209private OperationRep operationRep;
210@Autowired
211BankMetierImp bankMetier;
212public static void main(String[] args) {
213 SpringApplication.run(MeinproApplication.class, args);
214
215}
216 @Override
217 public void run(String... strings) throws Exception {
218 Client c1=clientRep.save(new Client("martin","martin@gmail.com"));
219 Client c2=clientRep.save(new Client("john","john@gmail.com"));
220
221 Compte cp1=compteRep.save(new CompteCourant("c1",new Date(),9000,c1,6000));
222 Compte cp2=compteRep.save(new CompteEpargne("c2",new Date(),63000,c2,12220));
223
224 operationRep.save(new Retrait(new Date(),6000,cp1));
225 operationRep.save(new Retrait(new Date(),10000,cp2));
226 operationRep.save(new Versement(new Date(),2000,cp1));
227 operationRep.save(new Versement(new Date(),20,cp2));
228 bankMetier.verser("c1",1000);
229 bankMetier.virement("c1","c2",2000);
230
231}
232}
233
234# DataSource settings:
235spring.datasource.url=jdbc:mysql://localhost:3306/monbank
236spring.datasource.username=roo
237spring.datasource.password=
238spring.datasource.driver-class-name=com.mysql.jdbc.Driver
239spring.jpa.show-sql=true
240spring.jpa.hibernate.ddl-auto=create-drop
241spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
242
2432017-02-12 16:15:24.858 INFO 6232 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2442017-02-12 16:15:24.860 INFO 6232 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2452017-02-12 16:15:24.863 INFO 6232 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2462017-02-12 16:15:24.947 INFO 6232 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2472017-02-12 16:15:25.113 INFO 6232 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2482017-02-12 16:15:25.938 INFO 6232 --- [ restartedMain] org.hibernate.tuple.PojoInstantiator : HHH000182: No default (no-argument) constructor for class: meinpro.entiti.Client (class must be instantiated by Interceptor)
2492017-02-12 16:15:26.209 INFO 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
250Hibernate: alter table compte drop foreign key FK2hw4shqsxc782lychpkr52lmv
2512017-02-12 16:15:26.228 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table compte drop foreign key FK2hw4shqsxc782lychpkr52lmv
2522017-02-12 16:15:26.228 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'monbank.compte' doesn't exist
253Hibernate: alter table operation drop foreign key FKkr9nfjf0ipqrw5xwcf9jqq6gv
2542017-02-12 16:15:26.229 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table operation drop foreign key FKkr9nfjf0ipqrw5xwcf9jqq6gv
2552017-02-12 16:15:26.229 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'monbank.operation' doesn't exist
256Hibernate: drop table if exists client
257Hibernate: drop table if exists compte
258Hibernate: drop table if exists operation
259Hibernate: create table client (code bigint not null auto_increment, email varchar(255), nom varchar(255), primary key (code))
260Hibernate: create table compte (type_cpte, varchar(2) not null, code_compte varchar(255) not null, data_creation datetime, solde double precision not null, decouvert double precision, taux double precision, code_cli bigint, primary key (code_compte))
2612017-02-12 16:15:26.712 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: create table compte (type_cpte, varchar(2) not null, code_compte varchar(255) not null, data_creation datetime, solde double precision not null, decouvert double precision, taux double precision, code_cli bigint, primary key (code_compte))
2622017-02-12 16:15:26.713 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' varchar(2) not null, code_compte varchar(255) not null, data_creation datetime,' at line 1
263Hibernate: create table operation (type_op varchar(1) not null, numero bigint not null auto_increment, date_operation datetime, montant double precision not null, code_cpte varchar(255), primary key (numero))
264Hibernate: alter table compte add constraint FK2hw4shqsxc782lychpkr52lmv foreign key (code_cli) references client (code)
2652017-02-12 16:15:27.146 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table compte add constraint FK2hw4shqsxc782lychpkr52lmv foreign key (code_cli) references client (code)
2662017-02-12 16:15:27.147 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'monbank.compte' doesn't exist
267Hibernate: alter table operation add constraint FKkr9nfjf0ipqrw5xwcf9jqq6gv foreign key (code_cpte) references compte (code_compte)
2682017-02-12 16:15:27.330 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table operation add constraint FKkr9nfjf0ipqrw5xwcf9jqq6gv foreign key (code_cpte) references compte (code_compte)
2692017-02-12 16:15:27.331 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Can't create table `monbank`.`#sql-23d4_77` (errno: 150 "Foreign key constraint is incorrectly formed")
2702017-02-12 16:15:27.332 INFO 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2712017-02-12 16:15:27.414 INFO 6232 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2722017-02-12 16:15:27.938 INFO 6232 --- [ restartedMain] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
2732017-02-12 16:15:28.776 INFO 6232 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2ffb82a2: startup date [Sun Feb 12 16:15:18 PST 2017]; root of context hierarchy
2742017-02-12 16:15:28.936 INFO 6232 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2752017-02-12 16:15:28.938 INFO 6232 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2762017-02-12 16:15:29.022 INFO 6232 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2772017-02-12 16:15:29.022 INFO 6232 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2782017-02-12 16:15:29.112 INFO 6232 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2792017-02-12 16:15:29.263 WARN 6232 --- [ restartedMain] .t.AbstractTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2802017-02-12 16:15:30.063 INFO 6232 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2812017-02-12 16:15:30.159 INFO 6232 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2822017-02-12 16:15:30.246 INFO 6232 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
283Hibernate: insert into client (email, nom) values (?, ?)
284Hibernate: insert into client (email, nom) values (?, ?)
2852017-02-12 16:15:30.461 INFO 6232 --- [ restartedMain] utoConfigurationReportLoggingInitializer :
286
287Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2882017-02-12 16:15:30.472 ERROR 6232 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
289
290java.lang.IllegalStateException: Failed to execute CommandLineRunner
291 at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
292 at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
293 at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
294 at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
295 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
296 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
297 at meinpro.MeinproApplication.main(MeinproApplication.java:30) [classes/:na]
298 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
299 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
300 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
301 at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
302 at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.1.RELEASE.jar:1.5.1.RELEASE]
303Caused by: org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): meinpro.entiti.Compte; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): meinpro.entiti.Compte
304 at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:333) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
305 at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
306 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:491) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
307 at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
308 at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
309 at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
310 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
311 at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
312 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
313 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
314 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
315 at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
316 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
317 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
318 at com.sun.proxy.$Proxy86.save(Unknown Source) ~[na:na]
319 at meinpro.MeinproApplication.run(MeinproApplication.java:38) [classes/:na]
320 at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
321 ... 11 common frames omitted
322Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): meinpro.entiti.Compte
323 at org.hibernate.id.Assigned.generate(Assigned.java:34) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
324 at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
325 at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
326 at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
327 at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
328 at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
329 at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:775) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
330 at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:748) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
331 at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:753) ~[hibernate-core-5.0.11.Final.jar:5.0.11.Final]
332 at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1146) ~[hibernate-entitymanager-5.0.11.Final.jar:5.0.11.Final]
333 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
334 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
335 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
336 at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
337 at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
338 at com.sun.proxy.$Proxy82.persist(Unknown Source) ~[na:na]
339 at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:508) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
340 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
341 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
342 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
343 at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
344 at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:504) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
345 at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:489) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
346 at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
347 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
348 at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
349 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
350 at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
351 at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
352 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
353 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.6.RELEASE.jar:4.3.6.RELEASE]
354 at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.6.RELEASE.jar:4.3.6.RELEASE]
355 ... 22 common frames omitted
356
3572017-02-12 16:15:30.478 INFO 6232 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2ffb82a2: startup date [Sun Feb 12 16:15:18 PST 2017]; root of context hierarchy
3582017-02-12 16:15:30.483 INFO 6232 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
3592017-02-12 16:15:30.485 INFO 6232 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
3602017-02-12 16:15:30.485 INFO 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
361Hibernate: alter table compte drop foreign key FK2hw4shqsxc782lychpkr52lmv
3622017-02-12 16:15:30.488 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table compte drop foreign key FK2hw4shqsxc782lychpkr52lmv
3632017-02-12 16:15:30.489 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Table 'monbank.compte' doesn't exist
364Hibernate: alter table operation drop foreign key FKkr9nfjf0ipqrw5xwcf9jqq6gv
3652017-02-12 16:15:30.499 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table operation drop foreign key FKkr9nfjf0ipqrw5xwcf9jqq6gv
3662017-02-12 16:15:30.500 ERROR 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : Can't DROP 'FKkr9nfjf0ipqrw5xwcf9jqq6gv'; check that column/key exists
367Hibernate: drop table if exists client
368 Hibernate: drop table if exists compte
369 Hibernate: drop table if exists operation
370 2017-02-12 16:15:30.879 INFO 6232 --- [ restartedMain] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
371 Process finished with exit code 0
372
373@Id
374private String codeCompte;
375
376public CompteEpargne(String s, Date date, int i, Client c2, double taux) {
377 this.taux = taux;
378}
379
380public CompteEpargne(String codeCompte, Date dataCreation, double solde, Client client, Collection<Operation> operations, double taux) {
381 super(codeCompte, dataCreation, solde, client, operations);
382 this.taux = taux;
383}
384
385public CompteCourant(String s, Date date, int i, Client c1, double decouvert) {
386 this.decouvert = decouvert;
387}
388
389public CompteCourant(String codeCompte, Date dataCreation, double solde, Client client, Collection<Operation> operations, double decouvert) {
390 super(codeCompte, dataCreation, solde, client, operations);
391 this.decouvert = decouvert;
392}
393
394Compte cp1=compteRep.save(new CompteCourant("c1",new Date(),9000,c1,6000));
395Compte cp2=compteRep.save(new CompteEpargne("c2",new Date(),63000,c2,12220));
396
397public CompteEpargne(String s, Date date, int i, Client c2, double taux) {
398 this(s, date, i, c2, new ArrayList<Operation>(), taux);
399}
400
401@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id", unique=true, nullable=false) public Long getId() { return this.id; }
402
403@DiscriminatorColumn(name = "TYPE_CPTE,",discriminatorType= DiscriminatorType.STRING,length = 2)
404
405@DiscriminatorColumn(name = "TYPE_CPTE",discriminatorType= DiscriminatorType.STRING,length = 2)