Help 2 « Query « JPA Q&A





1. Help with org.hibernate.Query    forum.hibernate.org

I have a bit of code that I cant get to work when I use parameters but when I hard code the value the query works correctly. Below is my code. As written the result is an empty list. If I replace the '?' with a hardcoded '1' it works correctly. I verified that the dynamic value passed in is also ...

2. Need Help with hibernate Query    forum.hibernate.org

I've got the following SQL query which works. I've got a Project object mapped to the project table with a collection mapped to Status table as StatusHistory, and another 1-1 mapping to the Status table as currentStats. I have been trying to figure out how to represent this query in either HQL or the Criteria API. I would prefer the Criteria ...

3. help with HQL query    forum.hibernate.org

Looks like the postgres dialect doesn't have a dateadd function. Does postgres? If it does, and if you're willing to recompile your hibernate jar, you could registerFunction whatever the dateadd function postgres provides, then use it in HQL. Have a look in PostgreSQLDialect.java. Add a registerFunction in where all the others are. If postgres doesn't have a function that adds to ...

5. Help with Datestyle query    forum.hibernate.org

6. query in many-to-many ORM problem,ask for help!    forum.hibernate.org

/** *the ORM between Category and Product is many-to -many *@author GanChunming *Creation time 2006-8-8 12:44:26 * @param category * @param pageused for dipart page * @param security:purview setting * @return */ public List searchWithProduct(IPojo category, Page page, ISecurity security) { Session session = HibernateUtil.currentSession(); Transaction tr = session.beginTransaction(); StringBuffer hql = new StringBuffer(); hql.append(" from Category as cat join fetch ...

7. Collection query help    forum.hibernate.org

I am having difficulty constructing a Hibernate query, and would like some help if possible. I have a class UserProfileRecordImpl that contains user profile information in a table profile_tbl. I also have a class KeywordRecordImpl that contains keywords in a table keyword_tbl. I've created a many-to-many association using a join table profile_keyword_tbl that allows users to enter keywords describing their profile. ...

8. Hibernate query help    forum.hibernate.org

Hi I need a help on Hibernate Query I have class Task which contains List of NEs ,the relation between these two classes is one-many,so I have created two tables named as task and ne. the structure of task table looks like this Table name task id key time type and structure of ne table is id name displayname fk. now ...





10. Help translating SQL Server query to HQL    forum.hibernate.org

Hi, I have the following sql server query that needs to be translated to hql. All of the tables in the query have relative hibernate mapping files. How would I write something like this in HQL? thanks in advance! select org.name,sum(CAST(e2.value as int)) from dat_element_instance e2, dat_payment_element pe2, dat_provider_involvement pi1, dat_payment p2, dat_provider prov, dat_participant par, dat_organization org where pe2.payment_id in ...

11. Someone could help me on creating a hibernate query?    forum.hibernate.org

Hello! I'm new to Hibernate and I would like someone to describe me how to get data from two tables using hibernate with the following condition: ------------------------------------------------------------------- | | table Users: email(pri), name, age; 1-----N table Reports: id(pri), email(fk), report, date; How would be my mappings either? Well, I would like to get all data in Reports table and all data ...

12. Help with HQL Query please !!!!    forum.hibernate.org

Hi, I'm looking for some help on how to write a HQL query on my database. I have the SQL needed to get my results but don't know how I should write this in HQL. I don't think I need to supply the hbm.xml files but if you think it may be necessary then I will do that. Any Help would ...

13. Ordered Set help    forum.hibernate.org

Hi, I've been looking around for a bit but cannot find much information on ordered sets. I have 2 classes one of which contains a set of the other. I want to be able to return the set ordered by a column of the second class (STATEMENT_CODE). In the CertType.hbm file I can order the set by either column in the ...

14. Help with HQL query    forum.hibernate.org

Hi experts I am new to Hibernate and think it is great. I have a query and can't find how to write it in HQL. Part Table ========== part_id (key) name Product Table ========== product_id (key) title Many to Many relationship primary product to part Product_Part table is used to track the relationship but it is not an entity. I Want ...

15. help me in HQL Query    forum.hibernate.org

Plz can any one help me in this query , first i m trying it by HQL My HQl Query is String query="select o.keyword,o.overturevolume from OvertureMasterSetter as o where exists (select m.keyword,m.overturevolume from OvertureMasterSetter m where m.prid='"+projectId+"' and o.overturevolume = m.overturevolume having count(m.overturevolume)>1 )"; Query qr=session.createQuery(query); List list=qr.list(); when i run this it gives that upexpected token having................but the same query ...

16. Need help to use query.getResultList()    forum.hibernate.org

HI: I am using javax.persinstence.EntityManager and javax.persinstence.Query to access postgress table. I do get a list back from the query (list size > 1) But, I am having problem to cast my entity object to list object. Below is my code - Query q = getEntityManager().createQuery( query string); java.util.list l = query.getResultList(); What I would need to do is to get ...





17. Sclar queries, need urgent help!!!    forum.hibernate.org

18. Need help with a query    forum.hibernate.org

I have the following tables. Site SiteID (PK) ... LevelID LevelPriceRangeList LevelID (PK) PriceRangeID (PK) PriceRange PriceRangeID (PK) Start End ... I have EJB entities for the Site table and the PriceRange table. In the Site table I have a JoinTable relationships that gives me a Set. It all works great, except I want a query that will give me a ...

19. Help with an HQL Query    forum.hibernate.org

I'm using spring with hibernate and I am trying to perform an HQL query, I'm using the following code to invoke the query: Code: List userList = getHibernateTemplate().find(HQLQuery); And this is what HQLQuery contains: Code: from controldeutiles.model.businessobject.User u where u.type = 'R' When the application execute this the followin error is shown: Code: java.lang.NoClassDefFoundError: antlr/ANTLRException at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:35) ...

20. Help with Hibernate's Criteria query    forum.hibernate.org

I have to perform left outer join on 2 tables, omit nulls & specify additional restrictions during join condition. SQL looks like this: select * from dd left outer join nwd on dd.Id = nwd.Id and nwd.div=17 where and dd.year=2007 and nwd.Id is null The highlighted condition has to be specified in the join ON clause ONLY to get the required ...

21. Help with HQL query minelement and maxelement    forum.hibernate.org

22. Help with HQL query :)    forum.hibernate.org

23. HQL Query help needed    forum.hibernate.org

Hi, I have two tables called document and documentattachement. documentattachement table has a foreign key in its documentid column which refers to the document tables's documentid(primary key). So when i load a document object using the HQL, all the documentattachement objects are getting loaded as a collection in the document entity class. But i need only the document objects to get ...

24. Need Help in Query inside another Query    forum.hibernate.org

Hi All, I have a following query How can i do: select tckno from issues where id=(select max(id) from issues); Do I need to Write the Query Twice like first for 1. selecting the max(id). Then 2. Selecting the tckno. Or How can I do it at once. Also How Can I use the functions in Hibernate like : between, in, ...

26. Need help with Criteria query    forum.hibernate.org

27. need help on serach hql query    forum.hibernate.org

28. Can someone help me construct this query?    forum.hibernate.org

I'm still getting confused over how to use the HQL query language to do this. I have a user table and a profile table that are linked by uid, and a company table that has a cid and a uid. What Im trying to do is return all users for a specfic cid, but I also want all of the users ...

29. Desperately need help troubleshooting query lockup problem    forum.hibernate.org

Newbie Joined: Fri Sep 14, 2007 1:22 am Posts: 1 Hello, I'm having one of those problems where I just don't know where to begin. My hunch is that this is not originating from Hibernate, but then again, I'm really clueless, but this seems like the logical place to start. Hopefully somebody can give me some ideas on where to begin ...

30. Need help with HQL Query or Criteria    forum.hibernate.org

31. Need help with HQL query    forum.hibernate.org

I have a Category domain object. In my categories table I added an extra column item_count that is updated by a trigger. I have added a new CategorySummary object that contains the Category with the item_count. class CategorySummary { private Category category; private int nrOfItems; public CategorySummary(Category cat, int nrOfItems) { .... ... } } I want to build and fill ...

32. Help with an HQL query    forum.hibernate.org

I'm using Hibernate to write a small application to get used to it. I need to use HQL for a couple of complex queries but I don't know how to do what I want. These are the classes that I have: Class Date, with an identifier, the day, month, and year. Class Meeting, with an identifier and description. Class Place, with ...

33. Help with having clause    forum.hibernate.org

Hi, I am new to hibernate and trying to create a DetachedCriteria for the following sql statement: select foreign_key_id from tableX where location = 1 GROUP BY foreign_key_id, rank having count(foreign_key_id) = case rank when 3 then 1 else 2 end Note: Object name is ObjectX and property names are same as column name Please let me know, if you want ...

34. Query Help- too many joins resulting in cartesian product    forum.hibernate.org

Hi. I have been playing around with hibernate where I work for some time now. I am getting good at it, and the hurdles I am facing now is in making HQL queries. I can write HQL, i think its just plain inefficient. My Object looks like this: Code: class TShirt -has many -> ...

35. Need help with Join Query    forum.hibernate.org

Hello, I am trying to run the query below, which is supposed to return a list of "Group" objects. When I run it, I get a "Object" that contains a Group and a UserGroup object. I need it to run a Group - what am I doing wrong that is preventing this from coming back a Group object? Thanks Code: ...

36. Hard query with rownums on SQL Server - help needed    forum.hibernate.org

Hi, I want to use hibernateTemplate.Find(query, paramValues) to execute such query select A.* from PersonModel A inner join ( select row_number() over(order by B.SIZE) lp, B.PERSONID p from CarModel B ) window on window.p = A.ID and window.lp between 34 and 55 order by window.lp How to create HQL QUERY if there is no inner join "ON" in HQL language - ...

37. Need Help - Convertion Query to Criteria...    forum.hibernate.org

Well, a good place to start would be gathering a solid understanding of how the Criteria API works. Here's a very simple tutorial on how to get started with the Hibernate3 Criteria API: http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=09howtousethecriteriaapi With the Criteria API, you need objects, not tables. So the table names you provide aren't really relevant - what is relevant is the object, or objects, ...

38. Need help expressing a query    forum.hibernate.org

public static void main(String args[]) { Session session = HibernateUtil.beginTransaction(); Criterion c1 = Restrictions.gt("id", (long)2); Criterion c2 = Restrictions.lt("id", (long)8); Criterion c3 = Restrictions.isNotNull("emailAddress"); User user = new User(); user.setEmailAddress(".com"); Example c4 = Example.create(user); c4.enableLike(MatchMode.END); c4.ignoreCase(); Criteria criteria = session.createCriteria(User.class); ...

39. HQL-query help    forum.hibernate.org

Session session = HibernateUtil.beginTransaction(); String hql; hql= "from User as u GROUP BY u.id HAVING u.id > 4)"; Query query = session.createQuery(hql); List users = query.list(); for (int i = 0; i < users.size(); i++) { User user = (User) users.get(i); System.out.println("Hello World"); System.out.println(user.getLoginName()); } HibernateUtil.commitTransaction();

40. Need help with a query    forum.hibernate.org

Hi, all: I am using Hibernate 3.2.6 and MS SQL Server 2005. I need help on writing two Hibernate queries that seem complex to me. These are my tables: 1. ROLE - role_id (primary key), name 2. APPLICATION - app_id (primary key), name 3. PERMISSION - perm_id (primary key), role_id (foreign key), app_id (foreign key) 4. USER - user_id (primary key), ...

41. Help with query    forum.hibernate.org

Hi all, I need help with the following query.... Code: ------------------------------------------------------------------------------- select distinct queue from Queue queue join queue.queueSongRequestLookups queueLookup where queueLookup.songRequest.songRequestStatusType = ? ----------------------------------------------------------------------------- Basically here we have 3 tables; Queue , songRequest, and queueSongRequestLookup. There is a many to many relationship between Queue and songRequest so queueSongRequestLookup is the lookup table. Now what I want is only the Queues ...

42. Help on join query    forum.hibernate.org

In my system I have the following objects: File Category User Role Permission Files belong to one or more categories Users can have one or more roles A permission can refer to a file or a category of files (never both) A permission can refer to a user or role (and so affecting all users in that role) (never both user ...

43. need help with the creation of hibernation query    forum.hibernate.org

hi all, I needed to convert a query to hibernate method. The query i am using is Select rollno,student_name,remarks from student where rollno=? and remarks like '%passed ? and failed ?' i am having a column called remarks which will have string value but last elements will be passed 4 and failed 2. so how to convert to this to a ...

44. Need help with logical query    forum.hibernate.org

I need to retreive rows based on an expression, here is the case id name countrycode 1 joe CA 2 mark FR 3 max XX i need a query that will look for an entry where countrycode=CA, if nothin exist, it will return XX for instance, if i ask the name where countrycode=CA, it will return joe. If i as a ...

45. Help translating a self-referential query into HQL or Criter    forum.hibernate.org

I need help with a query, translating it to either HQL or Criteria. I have a table containing a long id, a long reference to another object, a timestamp, and a float representing a dollar value. Nothing fancy, so the resultant table looks like... | id | other_id | timestamp | dollars | And the class mapped to this table contains ...

46. Help formulating a query/criteria    forum.hibernate.org

I have a model/Object, aModel it has two columns/properties those two columns have the same type: public class aModel User origiUser User substituteUser ... basically a the model has two prperties of the same type, User (note that User model has property userID), and substituteUser is nullable. now the problem is this, given a userID I would want to retrieve all ...

47. Help with defining a Criteria based query?    forum.hibernate.org

public class AppUser extends IDEntity { private int ID; .... } public class FullExpert extends AbstractExpert { private in AppUserID private Set Owners = new LinkedHashSet(); ...

48. Help with Query    forum.hibernate.org

I have an object tree with 3 levels of nested one-to-many relationships: A has-a Set, B has-a Set and C has-a Set All the set mappings are like this one in A.hbm.xml: Code: ...

49. Help on HQL query    forum.hibernate.org

Hello, maybe some Hibernate Pro can help me with a HQL query. I'm sorry if this is not the right forum. I am developing a Forum software. In a Forum there can be many Messages (threads). A message can have multiple responses, which are also messages. The basic structure for a Message is: Message properties: -> Forum (forum object it belongs ...

50. Urgent need help in self join an query using criteria    forum.hibernate.org

Hi need help on self join and query. I have a sales_table with sales info and below are the below columns id item_id items_sold sale_time (time stamp) This table will have all the sales info for a given item id, and how many items sale and at what time it was sale. Now the challenge is i need to generate a ...