hql

hql query to fetch data and sum of amount

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:04:30
问题 I am writing query to fetch data from tables my hql query is SELECT distinct bd FROM BillDetails AS bd LEFT JOIN FETCH bd.customerDetails AS cd LEFT JOIN FETCH bd.billProductList AS bpd LEFT JOIN FETCH bpd.product AS pd WHERE bd.billNo=:id AND bd.client.id=:cid Above query is working properly I want to write query to fetch sum of all amount field of billPaidDetailses . billPaidDetailses is a list in BillDetails class. I am trying following query for that but it is not working String hql =

HQL Query to get fields from @ElementCollection

限于喜欢 提交于 2019-12-13 04:44:59
问题 I'm trying to construct an HQL query to pull properties from an @ElementCollection: public class Resource { @Id private String name; @ElementCollection() @CollectionTable( name = "property", ) @SortNatural private final SortedMap<String, String> properties = Maps.newTreeMap(); } The property table is using the default column names ( properties and properties_key ) to store the data (with a foreign key back to my resource table). I have the following HQL query, where I'm trying to return the

Why is this HQL search query not working?

江枫思渺然 提交于 2019-12-13 04:35:30
问题 I have the following model; I have users and rules and teams a user can be added to 0, 1 or more rules a user can be added to 0, 1 or more teams a rule can be added to one team only, but a team can contain many distinct rules a rule can contain 0, 1 or more users Here is the UserEntity class: class UserEntity { private String username; private List<TeamEntity> teams; private List<RuleEntity> rules; @Column(name = "username", nullable = false, unique = true) public String getUsername() {

Table name as parameter in HQL

浪子不回头ぞ 提交于 2019-12-13 04:35:04
问题 Let's assume we have the HQL query: String ageQuery = "select age from people where name = :name"; Session session = getSession(); Query query = session. createSQLQuery(nameQuery). setParameter("name", "Thomas"); // query.list(); returns the result But what if I want to parametrize the table name? One can't use it like this: String ageQuery = "select :table from people where name = :name"; Session session = getSession(); Query query = session. createSQLQuery(ageQuery). setParameter("table",

How to use Spring MVC to update current user data?

有些话、适合烂在心里 提交于 2019-12-13 04:05:19
问题 I'm beginner to learn spring MVC, Now I have a problem can't solve. I spent a lot of time want to use Spring MVC to update current user data,but always go round in circles. For Example login user is [test2] and I want to update mAccount and mPassword,how to get login session and click jsp form to update.What should I do?(mId is Primary Key) eclipse console message: enter image description here eclipse debug mode message: enter image description here Bean: private Integer mId; private String

hibernate executeUpdate IndexOutOfBounds

。_饼干妹妹 提交于 2019-12-13 02:38:42
问题 I am trying to use an HQL to perform a simple update in hibernate, but i can't seem to get it to work. i have a query template defined as: private static final String CHANGE_DEVICE_STATUS = "UPDATE THING" +"SET ACTIVE = ? " +"WHERE ID = ?"; and then i try to execute it like this: Session s = HibernateSessionFactory.getSession(); Query query = s.createQuery(CHANGE_DEVICE_STATUS); query.setBoolean(0, is_active); query.setLong(1, id); query.executeUpdate(); But now i get this error: java.lang

unexpected token : ( subquery hql

落花浮王杯 提交于 2019-12-13 02:27:20
问题 Here's my HQL query FROM com.mysite.ActeurInterne act WHERE act.acteurId IN (SELECT DISTINCT COALESCE(acteurInterne.acteurInternePrincipalId, acteurInterne.acteurId) FROM (SELECT DISTINCT acteurInterne FROM com.mysite.ActeurInterne AS acteurInterne JOIN acteurInterne.roleSet.roles AS role WHERE acteurInterne.acteurId = acteurInterne.acteurId AND acteurInterne.nom LIKE :likenom AND (role.dateFermeture IS NULL OR role.dateFermeture >= TRUNC(SYSDATE)) AND (role.dateOuverture IS NULL OR role

SQL to HQL query Grails

纵然是瞬间 提交于 2019-12-13 00:08:51
问题 I have an SQ: query which I want to use in Grails but need to convert it to HQL so I could use it for findAll method. The code goes like artifacts = Artifact.findAll( "FROM Artifact WHERE id NOT IN ( " + "SELECT artifact_id FROM Classification " + "WHERE active = :active) AND document_id =:doc_id", [active: '1', doc_id:document.id, max:limit, offset:startIndex]) This is giving me stringIndexOutofBounds error. I think it s probably because of the syntax because the SQL works fine on the

Query syntax error when bulk-deleting in Hibernate

99封情书 提交于 2019-12-12 21:48:59
问题 I try to executer bulk delete using Hibernate HQL query, following reference manunal but I get a query syntax error. This line final Query qry = getSession(false).createQuery(" delete from NewCalendarDay"); causes exception: org.hibernate.QueryException: query must begin with SELECT or FROM: delete [ delete from pl.com.bms.avaro.staticData.model.NewCalendarDay ] Class in which the code is executed extends org.springframework.orm.hibernate3.support.HibernateDaoSupport , so getSession() method

how to get list of long values in hibernate from the table while casting from bigint to long

随声附和 提交于 2019-12-12 19:19:44
问题 I get the following exception when using the getEvents method: org.hibernate.MappingException: Unknown entity: java.lang.Long public List<Long> getEvents(Person person) { String q = "select new java.lang.Long(te.event_id) " + "from teachers_event te" + "where te.teachers_id = :personId "; Query query = entityManager.createNativeQuery(q, Long.class); query.setParameter("personId", person.getId()); return (List<Long>) query.getResultList(); } The teachers_event table in database connects the id