hql

JPA spring boot inner join - with-clause referenced two different from-clause elements error

微笑、不失礼 提交于 2019-12-08 06:30:01
问题 I'm trying to select with a inner join in one of my JPA repositories the query: @Query(value = "select wm.WagerIdentification, wm.BoardNumber, wm.MarkSequenceNumber, wm.MarkNumber," + " pt.CouponTypeIdentification, pt.WagerBoardQuickPickMarksBoard " + "from WagerBoard wb " + "inner join wb.listOfWagerMarks wm on wb.WagerIdentification = wm.WagerIdentification and wb.BoardNumber = wm.BoardNumber and wb.GameIdentification = wm.GameIdentification and wm.meta_IsCurrent = 1 " + "inner join wb

where employer.employees.gender = 'm', or how to filter a list of Items on a field of Item?

自作多情 提交于 2019-12-08 05:30:00
问题 An employer has many employees (a one-to-many relationship). Here is how I select the employees for a given :employer : select employer.employees from Employer employer where employer = :employer I would like to filter the results to get only the employees which gender field is m . How could I achieve this using HQL? Is there any clause that I haven't noticed in the doc? Ideally, something like: and employer.employees.gender = 'm' Or: and each(employer.employees).gender = 'm' 回答1: Try this

Get spatial points within radius using NHibernate Spatial

可紊 提交于 2019-12-08 04:34:22
问题 I'm currently trying to naivly get the k-nearest neighbors of a set of points, given a value k, a coordinate to use as center and a radius serving as the max distance to find points within. I'm using geographical points (SRID 4326) on a MSSQL 2008 database. The neighbors are naivly found ordering the query by the distance to the point and limiting the result. My trouble starts at limiting the points by the given radius. The distances returned by the Distance function are much larger than

Hibernate Complex Join

流过昼夜 提交于 2019-12-08 04:25:40
问题 So we have 2 objects which each map to a db table. public class Dispute { private Long disputeSeqNo; private List<StatusInfo> statusInfos; } public class StatusInfo { private Long statusSeqNo; private Date createdDt; private String statusCd; private Dispute dispute; } A Dispute can have 0 or more StatusInfo's associated with it. Currently hibernate is returning all the StatusInfo objects for every Dispute. While in some cases this is desired. However I have a use case where: I only need to

Cannot query entities using JOIN

﹥>﹥吖頭↗ 提交于 2019-12-08 04:13:28
问题 I am trying to get my head around HQL and run it inside the Persistence window of IntelliJ IDEA. Here's the thing: I can run simple queries like these: hql> SELECT offer FROM OfferEntit offer; hql> SELECT offer FROM OfferEntit offer WHERE offer.id = 1L; but if I add something like a JOIN : hql> SELECT offer FROM OfferEntit offer JOIN offer.owner AS owner WHERE owner.id = 1L; I get an empty result. Always. No matter what I do. I have no idea why.. Also I checked whether those records exist -

Hibernate Annotation based Query executing Error?

こ雲淡風輕ζ 提交于 2019-12-08 03:13:57
问题 Actually in my Hibernate Annotation based Application have theree ValueObject classes(Bean class) these are.. public Class CourseVO{ @Column(name="NAME") private String name; } SKillsetVO class public Class SkillsetVO{ @ManyToOne @JoinColumn(name="COURSE_ID", insertable=false, updatable=false) private CourseVO courseSID; @ManyToMany(cascade = {CascadeType.ALL}, fetch=FetchType.EAGER) @JoinTable(name="SKILLSET_COURSE",joinColumns={@JoinColumn(name="SKILLSET_ID",referencedColumnName="S_ID")}

How to a write a Criteria query with multiple joins involved

走远了吗. 提交于 2019-12-08 03:08:10
问题 I'm trying to code the following HQL query using the Criteria API: var userList = _session .CreateQuery("select u from User u where u.Role.ID=3 and u.Customer.ID=:cID") .SetInt32("cID", 1) .List<User>(); (3 NHibernate objects : User(ID, Name, Role, Customer), Role(ID, Name) and Customer(ID, Name). I tried the following but it doesn't work because NHibernate tries to find a Customer associated with a Role: var userList = _session .CreateCriteria(typeof(User)) .CreateCriteria("Role") .Add

Converting Hibernate linq query to HQL

和自甴很熟 提交于 2019-12-08 02:58:18
问题 I understand that a IQueryable cannot be serialized. That means that queries can not be serialized, sent to a webservice, deserialized, queried and then sent back. I was wondering if it is possible to convert a hibernate linq query to hql to be sent over the wire. Is there another route I am missing? 回答1: I think I've seen ADO.NET Data Services as advertised to work with NHibernate: http://wildermuth.com/2008/07/20/Silverlight_2_NHibernate_LINQ_==_Sweet http://ayende.com/Blog/archive/2008/07

How to filter the child entity while quering the parent in hibernate

我是研究僧i 提交于 2019-12-08 01:54:44
问题 Lets say that i have two entities public class EntityA { @id @GeneratedValue @Column(name="id") private Long id; @OneToMany(mappedBy="EntityA") @JoinColumn(name = "entityA_id") private List<EntityB> entityBList; } public class EntityB { @Column(name = "MODEL_PERCENT") private BigDecimal modelPercent; @ManyToOne @joincolumn(name="entityA_id") private EntityA entityA; } What i want now is, when i fetch the EntityA i want to add a where clause to fetch all EntityBs' whose modelPercent is greater

HQL: get last element of collection

纵饮孤独 提交于 2019-12-08 01:14:44
问题 I have Person entity, which have many-to-many relationship with Address entity (which has some boolean property). This relationship represent with help of separate table (which is not an entity) I need a query like: "from Person p where p.addresses is empty or p.addresses.getLastElement.propert is TRUE" Question: Can I pull the last element of p.addresses collection in HQL question? If yes, How? If no, can I represent many-to-many relationship as entity? 回答1: Can I pull the last element of p