nest « Query « JPA Q&A





1. JPA Nested Select Left Outer Join    stackoverflow.com

Is it possible to do a nested select in JPA QL? How would I write the following SQL statement in JPA QL?

select * from preferences p left outer join (select ...

2. Join tables with nested select count and group by in Nhibernate HQL    stackoverflow.com

I have post, vote and comment table. Each post can have N votes and N comments. I have been trying to find a way to do this query using Nhibernate HQL ...

3. Projections for Collections and Nested Projections    stackoverflow.com

The first part is HOW TO PROJECT COLLECTIONS? Can We apply projections on collection elements? For e.g

    class User{
    private address List<Address>;
}

class Address{
    ...

4. Nested Select Using HQL    stackoverflow.com

I would just like to know if derived queries can be handled by HQL? I have this bit of code right here and it kept on saying that it did not ...

5. Hibernate Criteria for nested select    stackoverflow.com

I have sql select for which I want write criteria. I was googling some time, but cant find anything for "not in". My sql query:

select * from users where username not in(
select ...

6. NHibernate Nested query in FROM clause    stackoverflow.com

I’m having a problem with translating T-SQL query into Nhibernate query – or writing query that will return same results but will be properly written in NH query language (HQL, Criteria, ...

7. JPA Criteria API: How to select property in nested collection    stackoverflow.com

I have a class Customer and CustomerDependant entities. Customer has many dependants and are bi-direcional. I need to find customers filtering by name and dependant name. Similar in JPQL: select c join ...

8. Case statement with nested select in HQL    stackoverflow.com

I've problem to create a HQL statement for this SQL (Oracle).

SELECT 
 CASE WHEN Column1 = 'VALUE1' THEN (
  SELECT COL2 FROM Table1
 ) ELSE 
 Column3
END
 FROM TABLE2 WHERE ...

9. HQL / JPQL - Nested select on FROM    stackoverflow.com

I try to convert my SQL query into HQL or JPQL (I want to benefit of the object mapping). My SQL Request is :

SELECT * 
FROM (SELECT bde, MAX(creation_date) 
  ...





10. HQL subquery error about correlated nesting    forum.hibernate.org

In Java Persistence with Hibernate Charpter14 p660 The correlated subquery is: from User u where 10 < ( select count(i) from u.items i where i.successfulBid is not null ) I modify the correlated nesting example like these: from User u where 10 < ( select count(i) from u.items i where i.successfulBid.successful= true ) When I test it with Hibernate Tools 3.3.1 ...

11. selecting from nested queries    forum.hibernate.org

Hi all i have a problem selecting from a nested query. I need to do it this way as the where clause is being generated dynamically at run time using hibernate filters. here is the query. select com.channel_count,sum(com.order_count), sum(com.order_revenue), sum(com.order_margin) from ( select cm.customer.id, count(DISTINCT cm.channel.id) as channel_count, sum(cm.orderCount) as order_count, sum(cm.totalRevenue) as order_revenue, sum(cm.totalMargin) as order_margin from CustomerOrderCountMonthly as cm ...

13. Help on HQL Query with nested select    forum.hibernate.org

14. Nested select new query    forum.hibernate.org

15. Querying on nested properties    forum.hibernate.org

Hello, I'm relatively new to Hibernate (am actually porting over / abstracting much of my Castor-based code), and i've run into a snag. In Castor, you can query on nested properties such as "where answer.question.survey.id = 1". This dot notation works one level deep with Hibernate (such as "where survey.id = 1"), but seems to die when we go one level ...

16. Nested queries and distinct keyword    forum.hibernate.org

Hi. I am having problems with returning objects from the nested HQL queries. Here is an example: select distinct activity2, activity2.acttype, studact.status from StudAct as studact, Activity as activity2 " where studact.studid = 5 and studact.actid = activity2.actid order by activity2.acttype.resumealways DESC, studact.status DESC, activity2.acttype.sort ASC The problem is that the returned result cannot be casted to the Activity[]. If I ...





17. Nested instantiation using "select new"    forum.hibernate.org

We wanted to use nested new's feature, but as Hibernate didn't support it, we have done some custom changes in our Hibernate 2.1.6 source code in order to support it. The changed classes were: net.sf.hibernate.hql.QueryTranslator net.sf.hibernate.hql.SelectParser net.sf.hibernate.impl.IteratorImpl net.sf.hibernate.impl.ScrollableResultsImpl I would like to know if Hibernate Team has some interest to analyse this little contribution and maybe add this feature to future ...

18. Is there a limit to nested queries against the same table?    forum.hibernate.org

Hibernate version: 2.1.1 and 2.1.7c Name and version of the database you are using: Postgresql 7.4.1 Is there a limit to how many levels you can nest a subquery in HQL? I have this HQL query: Code: FROM EncounterCard AS enc WHERE enc.patientId = ? AND enc.encId = (SELECT ...

19. Order not working with nested properties    forum.hibernate.org

20. Left join in nested query: BUG with Hibernate 3    forum.hibernate.org

The following query: FROM it.saga.pubblici.tributi.TriDACCalcoloVoci as voce WHERE voce.pkid IN (SELECT v.pkid FROM it.saga.pubblici.tributi.TriDACCalcoloVoci as v LEFT JOIN v.sottoPeriodo as sp) do not work with Hibernate 3.0.3 and SQL Server, while it worked with Hibernate 2.1.6 and the same DB. The bug is in the translation from HQL to SQL because the result SQL query is: select [omississ] from TRI_CALCOLO_VOCI tridaccalc0_ ...

21. Ordering by Nested properties Criteria API    forum.hibernate.org

I tried it using dot notation which is how I would have expected it to be implemented and it didn't work. E.g. I have objects A, B. A has a B called 'b'. B has a property called 'name'. I tried criteria.addOrder(Order.asc("b.name")). Hibernate complains that it can't find the property b.name. It's works using properties of A so for example: criteria.addOrder(Order.asc("somePropertyName")) ...

22. JIRA? won't Criteria API resolve nested properties like HQL?    forum.hibernate.org

If Criteria API is the best choice for dynamicly building queries, for user-configured reports, for example, then it should be easier to add nested properties to the criteria. Currently, you must createAlias() or createCriteria() for each association in the query. Because there is no way to 'query' the Criteria object for existing aliases, the application developer must keep track of aliases ...

24. Unable to update a nested collection : unexpected row count    forum.hibernate.org

Newbie Joined: Thu Apr 20, 2006 9:35 am Posts: 10 Hi, I have a little problem with Hibernate mapping. Here is my mapping file : Code:

25. Criteria API, Order and nested properties    forum.hibernate.org

org.hibernate.QueryException: could not resolve property: parent.name of: Child at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43) at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:63) at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31) at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1294) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:434) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:394) at org.hibernate.criterion.Order.toSqlString(Order.java:45) at org.hibernate.loader.criteria.CriteriaQueryTranslator.getOrderBy(CriteriaQueryTranslator.java:348) at org.hibernate.loader.criteria.CriteriaJoinWalker.(CriteriaJoinWalker.java:82) at org.hibernate.loader.criteria.CriteriaLoader.(CriteriaLoader.java:68) ...

26. Criteria queries: filtering by object in nested collection    forum.hibernate.org

Hi, There are a lot of problems with querying a nested objects. Unfortunately I can not find any solution for my problem. My object model is like the following: Repository 1--* Device 1--* DevicePolicy *--1 Policy So: there is a Repository. There are Devices in the Repository. Every Device has a collection of DevicePolicies (a Set). Every DevicePolicy is made of ...

27. Nested new in hql queries    forum.hibernate.org

Hi! Is it possible to do nested instantiation (new()...) in a select?? The real case: I have a query like this Code: select distinct new SomeStrangeObject( (select count(id) from SomeObject where date=current_date()), (select count(id) from SomeObject where date

28. left join doesn't work in nested query    forum.hibernate.org

I have using hibernate 3. Problem is left join works if I have a simple query, but not in a nested query. If I have a nested query: select ... where i.id in(Select ... From Parent p left join p.children as c ....). In the debug log, the actual JDBC query is just ... From Parent p, Children c, there is ...

29. Error on ordering by nested subcriteria properties    forum.hibernate.org

Criteria crit = sess.createCriteria(Supplier.class); Criteria critAddressProvince = crit.createCriteria("addressProvince","addressProvince"); Criteria critAddressNation = critAddressProvince.createCriteria("nation","nation"); Order order = Order.asc("addressProvince.nation.code"); crit.addOrder(order);

30. Nesting Criteria within Criteria to form SubQuery    forum.hibernate.org

Hi All, I am using hibernate 3.0.5 with JDK1.5 on oracle 10G. I want to know how I can nest Criteria within another Criteria to form subqueries Given below is a very basic example of what I want to achieve. I have address table which has following columns Address_ID, line, zip, country I have Students table which has following columns Student_ID, ...

31. Criteria projection query with nested property    forum.hibernate.org

Hibernate version: 3.2 Code between sessionFactory.openSession() and session.close(): Session session = this.getCurrentSession(); Criteria crit = session.createCriteria(UniUnit.class); crit.createAlias("uni", "uni"); /* * prefix is needed to ensure the alias name is different from the property name * this is a workaround to problem where Hibernate uses alias names in where clause * http://opensource.atlassian.com/project ... se/HHH-817 */ final String prefix = PrefixedAliasToBeanResultTransformer.ALIAS_PREFIX; crit.setProjection(Projections.distinct(Projections.projectionList() .add(Projections.property("id.uniCode"), ...

32. How to Write nested query    forum.hibernate.org

33. HQL query nested select and Oracle    forum.hibernate.org

I have the following HQL defined: PROBLEM: Attempting to provide a 'snaphot' of associations at some timestamp. Instead of only grabbing the set of objects prior ...

34. Nested query doesnot work    forum.hibernate.org

Hi, i am trying to do something of the kind: select a, count(b) from (select limit 0 20 * from T order by c desc) group by a order by count(b) desc I am using HSQLDB, and when i try this query at their gui it does work. From the code using hibernate i get: QuerySyntaxException: unexpected token Seems when i ...

35. Nesting queries on views in Hibernate    forum.hibernate.org

Hi, I have multiple views in my database, and am trying to create a hibernate mapping which links the views to each other: VIEW1: FIELD1 FIELD2 FIELD3 (KEY FOR VIEW2) VIEW2: FIELD1 (MAP TO VIEW1.FIELD3) FIELD2 FIELD3 (KEY FOR VIEW3) VIEW3: FIELD1 (MAP TO VIEW2.FIELD3) FIELD2 Each of the "foreign keys" is used as part of a one-to-many relationship. However, when ...

36. Help--About nesting query    forum.hibernate.org

I have an entity: @Entity @Table(name = "TopicOrReply") public class TopicOrReply implements Serializable{ private Long id; private String randomCode; private String title; private String content; private TopicOrReply repliedTopic; .... } Explain: when title is NOT null, this records means a topic. repliedTopic is null in this case. when title is null, this records means a reply. repliedTopic is NOT null in ...

37. Criteria for nested aggregate query    forum.hibernate.org

38. Please suggest a way to implement nested query in hibernate    forum.hibernate.org

Hello everyone! I am farely new to Hibernate and just have read and implemented a couple of examples from the books I have read. However I am not being able to find a way to convert the following nested sql (which I am using for a jdbc resultset) into an equivalent in hibernate . Could you please suggest a way (or ...

39. HQL for nested set - failing query    forum.hibernate.org

Hey guys, Im having a problem with a query im trying to port from SQL to HQL. This HQL query is for a nested set (as per this article: http://dev.mysql.com/tech-resources/art ... -data.html ), however it fails on the sub-query in the from clause: Code: SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM Content AS node, ...

40. Nested Aggregate Function -- HQL Help    forum.hibernate.org

41. Creating nested query    forum.hibernate.org

42. Nested Select in HQl    forum.hibernate.org

43. HQL: How to order by an anonymous nested select    forum.hibernate.org

Code: SELECT DISTINCT u.email, su.metaInfo, (SELECT count(*) as viewCount FROM StatisticEvent se, Subscription s WHERE se.eventType = 'display' and se.subscription.id = s.id and s.campaign.id = 1 and ...

44. URGENT - Oracle view with nested select    forum.hibernate.org

Page 1 of 1 [ 1 post ] Previous topic | Next topic Author Message gireeshkg Post subject: URGENT - Oracle view with nested select Posted: Sun Jul 12, 2009 11:40 pm Newbie Joined: Sun Jul 12, 2009 11:31 pm Posts: 2 Hi, I have created a Oracle view with nested ...

45. Nested Query, please help    forum.hibernate.org