hql « Map « JPA Q&A





1. Map entity using query in Hibernate    stackoverflow.com

consider table

sales (id, seller_id, amount, date)
and here is a view that is generated from sales using query SELECT seller_id, SUM(amount) FROM sales GROUP BY seller_id
total_sales (seller_id, amount)
I want to make an ...

2. Get children count via HQL    stackoverflow.com

I have a one-to-many mapping between a parent entity and child entities. Now I need to find the number of children associated with each parent for a list of parents. I ...

3. Hibernate inheritance and HQL    stackoverflow.com

I have inheritance in Hibernate for where Connection is my parent entity, and MobilePhoneConnection is extended entity. I used one table per subclass strategy for inheritance mapping. This is my file:

<?xml ...

4. HQL query on map key : Column not found: SQLGrammarException    stackoverflow.com

I have the following model:

class A{
    Map<String, Integer> tags
}

class B{
   A a;
}
I need to find instances of B where its associated A has a certain key ...

5. Hibernate table mappings with annotations    stackoverflow.com

I'm just getting started with Spring/Hibernate and I'm trying to understand how hibernate maps entities to tables. Right now I'm working with the following classes to test out CRUD operation ...

6. returning Map in HQL    stackoverflow.com

I was going through hibenate documentation and found that it is possible to return map from HQL by using code:

select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as ...

7. hibernate hql how to get matched child from parent?    stackoverflow.com

two tables, Cat and kitten(one to many), there are 5 records in the kitten table, and 1 in the cat table. kitten have color, 2 in white and 3 in yellow. ...

8. Map-valued collections in HQL queries    coderanch.com

9. Mapping problem with a hql join    forum.hibernate.org





10. Can't use the Map key in HQL    forum.hibernate.org

Look on hibernate tests (HQLTests)- you will find how to work with MAP joins explicit and implicit: public void testDuplicateExplicitJoinFailureExpected() throws Exception { //very minor issue with select clause: assertTranslation( "from Animal a join a.mother m1 join a.mother m2" ); assertTranslation( "from Zoo zoo join zoo.animals an join zoo.mammals m" ); assertTranslation( "from Zoo zoo join zoo.mammals an join zoo.mammals m" ...

12. New to Hibernate: java map with HQL    forum.hibernate.org

Newbie Joined: Sun Feb 06, 2011 12:42 pm Posts: 2 Hi before i begin i know that here are already some questions regarding the java.util.map but i spend an hour and i cant seem to find the answer... Before i begin here is the code i have written so far: This is the entity: Code: @Entity public class StoryGroup implements Serializable, ...

13. HQL: How to query a Map atribute    forum.hibernate.org

Hi, I have class with a property map as an attribute: class Test { Map extraAttributes; /** * @hibernate.map table="TestExtraAttributes" * @hibernate.collection-key column="testId" type="long" * @hibernate.collection-index column="attributeName" type="string" * @hibernate.collection-element column="attributeValue" type="string" */ public Map getExtraAttributes() { return extraAttributes; } } Now I want a query to return only Test instances having special extra attributes: select distinct test from Test test ...

14. Inheritance and HQL Query problem    forum.hibernate.org

Hi All, Here are my datas : The Mapping file : Code: ...

15. Inheritance and HQL    forum.hibernate.org

Can I pass "class" parameter to query? I have such mapping: Code: ...

16. Question related HQL involving Parent and child objects    forum.hibernate.org

2.1.4: I wrote a HQL to select an entity and its relations in HQL expecting to get a single object array with entity and collections of childs as its elements. I know that its not necessary to select relations as Hibernate will fetch for me when required but in our case this fetch happens out of session scope(becuase we use session ...





17. Mapping problem with polumorphic tables and HQL    forum.hibernate.org

Hibernate version: 2.1.6 or 3.0alpha Name and version of the database you are using: Oracle 9i2 I am trying to add in support for our data tables in hibernate, but am running into some problems. Here is the basic setup: We have multiple servers with differents sets of data tables, let's call these form_a_data, form_b_data,etc. One server might have 3, another ...

18. How to write HQL with a Map mapping?    forum.hibernate.org

I have mappings like this: public class Foo { private Long id; private Map barMap; ...//getters, setters } public class Bar { private Long id; private String name; } with class Foo, the key of barMap is an object of Bar, and the value is a Date. ... ...

19. HQL Query using a Map    forum.hibernate.org

I am using Hibernate 2.1. I am wondering how to write an HQL query that takes a HashMap relationship I have set up at the object level into consideration. For example I have a map defined in my xdoclet as follows: Code: /** * @hibernate.map table="ed_landing_page_article" cascade="none" lazy="false" * @hibernate.collection-key ...

20. Problem with HQL query related to inheritance    forum.hibernate.org

Hi: I have a class Car, this class has a propierty owner which is a reference a class Person, which class has a reference a class Address which has a String Street. I have a class Company, which has a reference a class Employee which extends Person. When I want to execute session.find("from Company as c where c.employee.address.street = '30'"); its ...

21. UnsupportedOperationException with HQL containing map key    forum.hibernate.org

I'm trying to run the following HQL query: "from Foo where customProps['foo'] = 'bar'" and I'm getting an UnsupportedOperationException. Looking at section 14.8 of the documentation, it looks like this should be possible. Any idea why it's not working? Hibernate version: 3.0 Mapping documents:

22. HQL + maps + querying    forum.hibernate.org

[b]Hibernate 2.1.8[/b] Hi, I would like to ask you how to query map mapping using HQL. I have mapping eg.: And now I want to select A which has KEY1 column is 'X' and VALUE1 ...

23. querying maps using hql    forum.hibernate.org

thanks for pointing out the pt about objects. gavin - my problem is occuring with writing a query criteria for the map object. ...

24. HQL for an object containing a map.    forum.hibernate.org

I have a calendar object that have holidays (a map) which is a mapping of hol_name and hol_date. A map from string indices to dates: What does the HQL named query look like if I need to make a query which uses holiday name as an input variable parameter ...

25. problem with inheritance single per table hql    forum.hibernate.org

hey, In our project, we are currently developing with jdk 1.5(using generics) and we are using hibernate annotations (EJB 3.0). We have a problem with the SQL generated in a HQL when a single per table inheritance strategy is involved. Let me explain showing you an example. Starting from a inheritance single per table strategy as the following example @Entity @Table(name="A_TABLE") ...

26. hql query that returns parent only if none of child objects    forum.hibernate.org

Hello, I need help in finding a way how I can create an hql query that would return me parent object only if none of the child object match a where clause. e.g I have a parent->child relation between Person->Pets. Pets is a Set on Person. I want the hql query to be - return the person objects from db where ...

27. How can I write HQL to restrict a child by its ancestor?    forum.hibernate.org

Hello all. How can I write a query to restrict a child based on its distant anscestor? In my case, I have an object, you could call the grandfather or great grandfather. There are n levels of hierarchy between them. I need a query that can find all children with a specific name that have a specific ancestor. Heres my structure; ...

28. HQL and inheritance    forum.hibernate.org

Hi everyone. Hibernate version: 2.1.8 Mapping documents: Java classes: package mypackage; public abstract class PropertyValue extends BaseObject { public Long getId() { return id; } ...

29.  mapping and HQL    forum.hibernate.org

30. [HQL] Using a "like" comparison in a Map Collectio    forum.hibernate.org

Hello all, This is the setup: In my Document object, I have a collection (title) which consists of String map keys and String values. The object is stored on a database via a hibernate 3 persistence: ...

31. How can an HQL Query return a Map of Maps ?    forum.hibernate.org

32. HQL bulkUpdate and maps    forum.hibernate.org

Hibernate version: 3.1.2 Hi, I am hibernate newbie and have to perform a bulk delete on an entity. I wrote a HQL query in DML style but I always get a syntax error and I don't really understant why. The mapping class has a map component. Here's an extract of my mapping file: Code:

33. HQL on the second side of a many-to-many mapping    forum.hibernate.org

34. HQL on the second side of a many-to-many mapping    forum.hibernate.org

If you have mapped the many-to-many using the normal colleciton technique (using the many-to-many element), then ignore the CarPart table. It's hidden by hibernate. The query would be "from Car c where c.Parts.Name = 'door'", assuming that you've mapped "Parts" as the name of the collection containing a car's parts (i.e. you have a method Set getParts();).

35. HQL that test for existence of a key in a member map    forum.hibernate.org

Hi, I wonder if there is a simple HQL that will select based on the existence of a key in a member map of an object. For example, the following does not work for obvious reasons. from MyTable myobject where 'MyKey' in elements(myobject.map) Is there something to the effect of the following query fragment? from MyTable myobject where exists myobject.map['MyKey'] Thanks. ...

36. HQL Mapping    forum.hibernate.org

Hi, I need help on a basic question. I have 2 tables and i m fetching records by joing the tables using HQL. I have set the relationship in the mapping files. My question is if there is no physical relationship set(foreign key is not set) in the oracle tables, will my HQL work?? Please clarify. Thanks, PK

37. HQL Query to Pull Entities and All Child Entities    forum.hibernate.org

Okay, suppose I have a simple POJO class like this: Code: @Entitiy @Table(name="T_ORGANIZATION") public class Organization { private int organizationId; private Collection childOrganizations; @Id @GeneratedValue @Column(name="organization_id") public int getOrganizationId() { ...

38. HQL where map does not contain key    forum.hibernate.org

39. HQL query from two tables mapped to classes in a is... hiera    forum.hibernate.org

Hi, When performing a HQL query like this: from is.company.app.layer.Table1 table1, is.company.app.layer.Table2 table2 an error is returned saying: unexpected token: is near line... Running either from is.company.app.layer.Table1 table1 or from is.company.app.layer.Table2 table2 works just fine. So I guess that this class hierarchy starting with is... is causing this problem, as the "is" gets interpreted as a reserved word. If that's the ...

40. HQL for many-to-many mapping    forum.hibernate.org

41. Simple Question about Mapping And HQL    forum.hibernate.org

42. Need Set and Map Examples in HQL    forum.hibernate.org

43. problem using maps in hql    forum.hibernate.org