您好我想寫這個地方並獲取查詢和我得到一個錯誤如何編寫HQL右
Query query = session.createQuery("from Device d where d.customerRefId=:customerId " +
"left join fetch d.tradeInOldDevice ");
query.setParameter("customerId", "myId");
Set<Device> customerDevices= (Set<Device>) query.list();
錯誤:
2013-09-24 12:18:45,753 ERROR PARSER:56 - line 1:98: unexpected token: left
這就是設備的實體:
@Entity
@Table(name = "Devices")
public class Device implements Serializable, IHidingDeletable {
...
@ManyToOne(optional = true,fetch=FetchType.LAZY)
private Customer owningCompany
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "tradeInOldDevice")
@Cascade(CascadeType.ALL)
private Device tradeInOldDevice;
..
那就是顧客:
public class Customer extends AbstractCustomer {...}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "Customers")
@DiscriminatorColumn(name = "type")
public abstract class AbstractCustomer implements IVersionized, Serializable {
@Id
protected String customerRefId;
任何想法?
我想你已經留下了一些文本,同時張貼在這裏的代碼。 –
謝謝。我修好了它。 – rayman