Bonjour tout le monde,
j'ai besoin de faire une jointure entre deux entites 'Sales' et 'ProductInfo' dans ma requete qui import une liste de 'sales' mais je ne sais pas pourquoi ma jointure ne marche pas!
voila le code de l'erreur:
entity Sales:
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 java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: p near line 1, column 58 [SELECT s FROM com.project.core.domain.entities.Sale s, p FROM com.project.core.domain.entities.ProductInfo INNER JOIN s.offer INNER JOIN s.order INNER JOIN p WHERE p.product.Id=s.product.Id AND s.offer.activityId=:act AND s.order.orderDate BETWEEN :dtCreateFrom AND :dtCreateTo AND s.order.shipStat=:del AND s.order.orderStatus=:status] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1222) at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168) at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:271) at com.citrusstv.core.domain.services.SaleServiceImpl.findSales(SaleServiceImpl.java:49) at com.citrusstv.core.domain.services.SaleServiceImpl.exportSales(SaleServiceImpl.java:71) at $SaleService_18c914faac057.exportSales(Unknown Source) at $SaleService_18c914faac056.exportSales(Unknown Source) at com.citrusstv.core.domain.services.SaleServiceImplTest.testSalesExport(SaleServiceImplTest.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeMethod(Invoker.java:715) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:907) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1237) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1197) at org.testng.TestNG.runSuitesLocally(TestNG.java:1122) at org.testng.TestNG.run(TestNG.java:1030) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
entity ProductInfo:
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 @Entity @Table(name = "SALES") public class Sale implements Serializable { private Integer id; private Integer quantity; private Double price; private Product _product; private Offer _offer; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="RefSales") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Column(name="Quantity") public Integer getQuantity() { return quantity; } public void setQuantity(Integer quantity) { this.quantity = quantity; } public static Sale findById(int id) { return em().find(Sale.class, id); } private Order _order; @ManyToOne @JoinColumn(name = "RefOrders") public Order getOrder() { return _order; } public void setOrder(Order order) { _order = order; } @ManyToOne @JoinColumn(name = "RefProducts") public Product getProduct() { return _product; } public void setProduct(Product product) { _product = product; } @Column(name="productprice") public Double getPrice() { return price; } public void setPrice(Double price) { this.price = price; } @ManyToOne @JoinColumn(name = "RefOffers") public Offer getOffer() { return _offer; } public void setOffer(Offer offer) { this._offer = offer; } public void save() { if (getId() != null) { em().merge(this); } else { em().persist(this); } } }
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 @Entity @Table(name = "PRODUCTSINFO") public class ProductInfo implements Serializable { private Integer Id; private String name; private Product product; private Double productCost; @Id @Column(name="Ref") public Integer getId() { return Id; } public void setId(Integer id) { Id = id; } @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="RefProducts") public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } @Column(name="Name") public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="pxAProducts") public Double getProductCost() { return productCost; } public void setProductCost(Double productCost) { this.productCost = productCost; } }
Partager