- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到错误,我只能假设我的查询有问题。我正在尝试使用 JPQL 中的“new”关键字初始化一个类,如下所示:
@Query("SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, "
+ "po.due_date, po_part.id, po_part.part_quantity, "
+ "part.id, part.part_number, part.part_description "
+ "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
+ "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
+ "FROM Po po "
+ "LEFT JOIN po.partList po_part "
+ "LEFT JOIN po_part.part")
List<ShopOrder> getShopOrder();
Po_part.java
@Entity
@Table(name = "T_PO_PART")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Po_part implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "part_quantity")
private Integer part_quantity;
@ManyToOne
private Part part;
@ManyToOne
private Po po;
Po.java
@OneToMany(mappedBy="po",targetEntity=Po_part.class)
private List<Po_part> poList;
部分.java
@OneToMany(mappedBy="part",targetEntity=Po_part.class)
private List<Po_part> partList;
我的数据库如下所示:
ShopOrder.java
public ShopOrder(int po_id, long po_number, Date po_due_date,
long po_part_id, int part_quantity, int part_id, int
part_number, String part_decription, long plasma_hrs, long gring_hours,
long mill_hrs, long breakpress_hrs) {
错误:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: part near line 1, column 155 [SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, po.due_date, po_part.id, po_part.part_quantity, part.id, part.part_number, part.part_description part.plasma_hrs_per_part, part.grind_hrs_per_part, part.mill_hrs_per_part, part.brakepress_hrs_per_part) FROM com.htd.domain.Po po LEFT JOIN po.partList po_part LEFT JOIN po_part.part]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:304) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
... 72 common frames omitted
------------更新--------------------
@Query("SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, "
+ "po.due_date, po_part.id, po_part.part_quantity, "
+ "part.id, part.part_number, part.part_description, "
+ "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
+ "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
+ "FROM Po po "
+ "LEFT JOIN po.partList po_part "
+ "LEFT JOIN po_part.part part "
+ "LEFT JOIN po_part.part")
仍然给我以下错误:
Invalid path: 'part.id' [SELECT NEW com.htd.domain.ShopOrder(po.id,
po.po_numbe
--------------更新----------------------------------
部分.java
@OneToMany(mappedBy="part",targetEntity=Po_part.class)
private List<Po_part> partList;
Po.java
@OneToMany(mappedBy="po",targetEntity=Po_part.class)
private List<Po_part> partList;
public List<Po_part> getPartList() {
return partList;
}
Po_part.java
@ManyToOne
private Part part;
@ManyToOne
private Po po;
商店订单
public ShopOrder(int po_id, long po_number, Date po_due_date,
long po_part_id, int part_quantity, int part_id, int part_number,
String part_decription, long plasma_hrs, long grind_hours,
long mill_hrs, long breakpress_hrs) {
查询
@Query("SELECT NEW ShopOrder(po.id, po.po_number, "
+ "po.due_date, po_part.id, po_part.part_quantity, "
+ "part.id, part.part_number, part.part_description, "
+ "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
+ "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
+ "FROM Po po "
+ "LEFT JOIN po.partList po_part "
+ "LEFT JOIN po_part.part part"
+ "LEFT JOIN po_part.part")
List<ShopOrder> getShopOrder();
在您的更新中,您将传递对象,就像我传递变量一样。这是错误的吗?我仍然遇到同样的错误:
Invalid path: 'part.id' [SELECT NEW
------------更新--------------
Po.java
public class Po implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "po_number")
private String po_number;
@Column(name = "sales_order_number")
private String sales_order_number;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
@JsonSerialize(using = CustomLocalDateSerializer.class)
@JsonDeserialize(using = ISO8601LocalDateDeserializer.class)
@Column(name = "due_date")
private LocalDate due_date;
@Column(name = "status")
private String status;
@Column(name = "total_sale", precision=10, scale=2)
private BigDecimal total_sale;
@ManyToOne
@JoinColumn(name = "customer_id", referencedColumnName = "id")
private Customer customer;
@OneToMany(mappedBy="po",targetEntity=Po_part.class)
private List<Po_part> partList;
部分.java
@Entity
@Table(name = "T_PART")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Part implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "part_number")
private String part_number;
@Column(name = "part_description")
private String part_description;
@Column(name = "plasma_hrs_per_part", precision=12, scale=4)
private BigDecimal plasma_hrs_per_part;
@Column(name = "laser_hrs_per_part", precision=12, scale=4)
private BigDecimal laser_hrs_per_part;
@Column(name = "grind_hrs_per_part", precision=12, scale=4)
private BigDecimal grind_hrs_per_part;
@Column(name = "mill_hrs_per_part", precision=12, scale=4)
private BigDecimal mill_hrs_per_part;
@Column(name = "brakepress_hrs_per_part", precision=12, scale=4)
private BigDecimal brakepress_hrs_per_part;
@Column(name = "lb_per_part", precision=12, scale=4)
private BigDecimal lb_per_part;
@Column(name = "inventory_count")
private Integer inventory_count;
@ManyToMany
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@JoinTable(name = "T_PART_MATERIAL",
joinColumns = @JoinColumn(name="parts_id", referencedColumnName="ID"),
inverseJoinColumns = @JoinColumn(name="materials_id", referencedColumnName="ID"))
private Set<Material> materials = new HashSet<>();
@OneToMany(mappedBy="part",targetEntity=Po_part.class)
private List<Po_part> partList;
public List<Po_part> getPartList() {
return partList;
}
Po_Part
public class Po_part implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "part_quantity")
private Integer part_quantity;
@ManyToOne
private Part part;
@ManyToOne
private Po po;
商店订单
public ShopOrder(int po_id, long po_number, Date po_due_date,
long po_part_id, int part_quantity, int part_id, int part_number,
String part_decription, long plasma_hrs, long grind_hours,
long mill_hrs, long breakpress_hrs) {
最佳答案
part.part_description part.plasma_hrs_per_part 缺少一个冒号
--更新--
我制作了一个在我的服务器上运行的更简单的示例。
@Entity
public class Po extends UUIDIdentified {
private static final long serialVersionUID = 1L;
@OneToMany(mappedBy = "po", targetEntity = PoPart.class)
List<PoPart> poParts;
public List<PoPart> getPoParts() {
return poParts;
}
public void setPoParts(List<PoPart> poParts) {
this.poParts = poParts;
}
}
还有
@Entity
public class Part extends UUIDIdentified {
private static final long serialVersionUID = 1L;
@OneToMany(mappedBy = "part", targetEntity = PoPart.class)
List<PoPart> poParts;
public List<PoPart> getPoParts() {
return poParts;
}
public void setPoParts(List<PoPart> poParts) {
this.poParts = poParts;
}
}
和
@Entity
public class PoPart extends UUIDIdentified {
private static final long serialVersionUID = 1L;
@ManyToOne
Po po;
@ManyToOne
Part part;
public Po getPo() {
return po;
}
public void setPo(Po po) {
this.po = po;
}
}
还有
public class Poo {
public Poo(Po po, PoPart poPart, Part part) {
super();
this.po = po;
this.poPart = poPart;
this.part = part;
}
Po po;
PoPart poPart;
Part part;
public Po getPo() {
return po;
}
public void setPo(Po po) {
this.po = po;
}
public PoPart getPoPart() {
return poPart;
}
public void setPoPart(PoPart poPart) {
this.poPart = poPart;
}
public Part getPart() {
return part;
}
public void setPart(Part part) {
this.part = part;
}
}
最后我的查询具有正确的语法:
<query><![CDATA[SELECT NEW de.cc.persistence.base.Poo(po, poParts, part) FROM Po po LEFT JOIN po.poParts poParts LEFT JOIN poParts.part part]]></query>
关于java - 意外标记 : part near line 1, 第 155 列 [选择新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30763339/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为
当我尝试在 db2 中创建表时,它抛出以下错误 $ db2 CREATE TABLE employee(emp_id INT NOT NULL, emp_name VARCHAR(100)) sh:
我有: while (i < l) { if (one === two) { continue; } i++; } 但是 JSLint 说: Problem at line 1 chara
所以我有这个代码: char inputs[10] = ""; int numInputs = 0; while (numInputs < 10){ char c; printf("E
var ninja = { name: 'Ninja', say: function () { return 'I am a ' + this.name; }
我收到一个我不明白的错误,请注意,我是编码新手,所以这可能是一个简单的错误。 #include using namespace std; int main() { //Initialise Fahr
我正在使用 javascript 和 react,由于某种原因,我收到了一个奇怪的 token 错误。 这是发生错误的代码: renderNavBar() { if (!this.us
Closed. This question is off-topic。它当前不接受答案。
由于某种我无法解释的原因,编译器正在输出一个错误,指出它发现了一个意外的#else 标记。 这发生在文件的开头: #if defined( _USING_MFC ) #include "stda
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
这个问题在这里已经有了答案: Difference between sh and Bash (11 个答案) 关闭 2 年前。 我正在编写一个简单的 bash 脚本,我在 XX `(' unexpe
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 此问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-topic
我在 Windows 7 上编写了一个脚本,它不断给我一个错误“(此时出乎意料。”对于以下代码 if %vardns%=="NODNS" ( netsh interface ipv4 set ad
我正在尝试使用xmlstarlet(使用xpath)解析XML文件,但是出现语法错误,并且我不知道如何更正我的代码。 这是我的脚本: #!/bin/bash if [ $1=="author" ];
以下脚本旨在在目录中的所有文件上运行程序“senna”,并将每个文件的输出(保留输入文件名)写入另一个目录 for file in ./Data/in/*; do ./senna -iobta
我从 challengers.coffee 运行此代码,并收到错误 ActionView::Template::Error (SyntaxError: [stdin]:3:31:unexpected
我在 config.db.database; 行中有语法错误(意外的标记“.”)。这是我在文件中的代码 const config = require('../config/config') const
这一定很明显,但是我无法使它正常工作。我正在尝试传输应该用于构建$ classKey的对象,这反过来又导致删除所需的软件(amd64或i386)。好吧,这里的代码: $name = @("softwa
我正在使用 1.3.7 版学习 Grails,但我一直无缘无故地遇到以下语法错误: unexpected token: mapping @ line x, column y. 有一次,我通过运行“gr
我正在尝试找出这段Pascal代码的问题 function Factorial(n: integer): integer; begin if n = 0 then Result := 1
我是一名优秀的程序员,十分优秀!