relationship « Query « JPA Q&A





1. hibernate criteria - querying tables in n:m relationship    stackoverflow.com

I'm trying to build a query with hibernate criteria for the following scenario:

  • Two entities: Indicator and report (each with their own tables, classes etc.)
  • an indicator can be used in zero to ...

2. Querying Many-To-Many relationship with Hibernate Criteria API    stackoverflow.com

I've the following many to many relation: File 1 --- * File_Insurer * --- 1 Insurer. I'm trying to query this relation using the Criteria API (Active Record) to get Files ...

3. how to write delete query in hibernate for many to many relationship    stackoverflow.com

I have two beans user and virtualdomain

@Entity
@Table(name = "tblUser")

public class User implements Serializable {
    private Long id;
    private String username;
private String deleteflag;
    ...

4. Using Hibernate Criteria API To Query Many-To-One Relationships with Projections    stackoverflow.com

I am trying to use Criteria API in following scenario:

  • I have two tables, Schedule and Route (with their classes and mappings).
  • Route has many-to-one relationship with Schedule.
  • Route has an integer property sequence.
Now ...

5. How do I query through a many-to-many relationship using NHibernate Criteria and Lambda Extensions?    stackoverflow.com

In my database I have a Person table and an Event table (parties, meetings, &c.). This many-to-many relationship is represented through an Invitation table. Each Person can have many Invitations. Each ...

6. How to I create an HQL query to return objects in a many to many relationship?    stackoverflow.com

I have an application that includes 2 classes Club and Article. These are mapped in Hibernate as a many to many relationship. As a result, hibernate has created a table called CLUB_ARTICLE ...

7. Selecting one object from a one-to-many relationship in Hibernate    stackoverflow.com

I have two tables:

Job
job_id, <other data>

Job_Link
job_link_id, job_id, start_timestamp, end_timestamp, <other data>
There may be multiple records in Job_Link specifying the same job_id with the start_timestamp and end_timestamps to indicate when those records ...

8. How to dynamically order many-to-many relationship with JPA or HQL?    stackoverflow.com

I have a mapping like this:

@ManyToMany(cascade = CascadeType.PERSIST)
    @JoinTable(
            name="product_product_catalog",
        ...

9. NHibernate ICriteria/HQL get count of one-to-many relationships    stackoverflow.com

I am trying to do the following preferably with ICriteria but if I need HQL I'll use it. Given objects Company and Order, Order has a reference to two Companies: ToCompany ...





10. Hibernate Many-to-Many relationship query    stackoverflow.com

I have a class Person and each person can have documents with a specific language. The Person and Document classes are linked with a Many-To-Many relationship. My Java code looks like this:

@Table(name="person")
public ...

11. HQL: select entity Y's that has entity X in a many-to-many relationship?    stackoverflow.com

Assuming Y has a many-to-many relationship with X. From google, I got

from Y left join fetch y.xs x where x = ?
However, when I loop through the result and dump y.getXs(), ...

12. Hibernate: Query By Example involving one-to-many relationship    stackoverflow.com

I've recently started playing with the query by example component of the Criteria API and have run into a strange issue - an org.hibernate.QueryException is thrown when trying to perform a ...

13. HQL query related to many-to-many relationship    coderanch.com

Hibernate version: 2.1.7c I'm having a problem in getting the proper HQL for the follwong senario: Tables : ITEM (ItemID, name) ORDER (OrderID, Description) ITEM_ORDER (OrderID,ItemID) I have done the many-to-many relationship mapping. (In this, the ITEM has a set of Orders and The Orders has a set of Items) ITEM is defined as the inverse end. The records for ITEM_ORDER ...

14. Many to Many relationship Query in hibernate    coderanch.com

Hi Good People, I am stuck in many-to-many relationship problem in Hibernate. I have the following scenario: Table: cutomers (custid, custname) Table: Product (prodid, prodname) Table: Billing (billingid, custid, prodid) As you can see third table implementing M:M relationship. Now i want to display in the UI like : List of products along with total number of customers in each product. ...

15. JPA - A Simple Query with Relationships    coderanch.com

16. self referencing relationship - many selects from hibernate    coderanch.com

I'm using JPA with hibernate as the provider. I've implemented an entity with a self referencing relationship in order to be able to do nested categories. When I load the root node, hibernate generates one select for each entity in the tree in order to load the children. Im beginning to think, by the very nature of this type of tree, ...





17. Many-to-many relationship query    forum.hibernate.org

Newbie Joined: Mon Sep 29, 2003 6:47 am Posts: 7 Hi. I have a model where Users can be in many Groups, Users should have a Collection of Groups that they're in, and Groups should have a Collection of Users which are a member of the current group. Here is my mapping document: Code: ...

18. How to model a one to distinct, finite n relationship    forum.hibernate.org

How to model this? This is a not-infrequent idiom in the object world, and would be trivial to implement if I could write to the database myself....but in Hibernate it proves not-so-easy. Code: class Person { String name; Hand left; Hand right; } class Hand { int numberOfFingers int numberOfWarts ...

19. Querying Many-to-one relationships    forum.hibernate.org

Assume a user has a collection of address objects and each address object has a state object. I want to identify all users who has an address in a given state. I've searched the forums and documentation, but haven't found an example of such a query. How would I do this using HQL (preferably in one query)? Thanks for the help. ...

20. Simple existence query on many-to-many relationship    forum.hibernate.org

I have a User class, and an Event class. Users can attend many events. Events have many attendees. Writing a search in straight sql is simple, but I would like to use the HQL way if I can. Also I am really after the existence rather than a List, but obviously I can work that out in code if there is ...

21. Sorting a Many-to-Many relationship    forum.hibernate.org

Hello All, I'm having a problem sorting a list of objects in a many-to-many relationship. I've to two tables, MapView and MapLayerGroup and a relationship table called MapViewLayerGroups. I have defined a mapLayerGroups collection in the MapView object that contains a list of associated MapLayerGroup objects. What I want to do is sort this list based on a column in the ...

22. Criteria Query and Opposite Side of Many-to-One Relationship    forum.hibernate.org

I have 2 tables and objects: Car and User Car table: car_id update_user_id User table: user_id So I have them mapped as follows: .. .. I'm wondering how to construct a Criteria Query for getting all of the users that have been assigned as an ...

23. order by for one to many relationship    forum.hibernate.org

24. query unidirectional one-to-many relationship    forum.hibernate.org

hi there, i have a unidirectional one-to-many relationship "events" from a class user to a class event, i.e. a user has a set of events. but events don't know about user. it's unidirectional because the OO design has a clear dependency check and the event class really doesn't need to know about the user. now if i want to query events ...

25. Order-by in many-to-many relationships    forum.hibernate.org

Thanks - but yes I could see already that you can use a query or a sort. These are work arounds. A query works if you use a query EVERY place you access the collection, but it does not give you the ordered iterator of the order-by attribute. The sort attribute "might" work (you have to write your own comparator that ...

26. How to define order-by column in a many-to-many relationship    forum.hibernate.org

I have: in my project mapping file and I want to recover my itens order by its names. If I add order-by="name asc" in the I got a error that says "Caused by: org.postgresql.util.PSQLException: ERROR: column itens0_.name does not exist". I think that the Hibernate is searching for name in ...

27. Adding a where clause to sets in a many-to-many relationship    forum.hibernate.org

Hibernate version: 2.1.8 I have two hbm files: UserInfo and Group. Their relationship is "many to many". A where clause (where="enabled ='T'") is added on class definition of both hbms. Please take a look at them. As you see, I have a set of Group in UserInfo and a set of UserInfo in Group as shown in the hbm files. The ...

30. Many to one relationship to itself (Problem with HQL Query)    forum.hibernate.org

What is wrong with my code, Help me. Below is my java class, hibernate mapping in hbm.xml. and HQL Query I need to retrive the top level categories from table, means whose parentId = 0 Tabel data id name shortName parentId 1 A a 0 2 B b 0 3 A1 a1 1 4 C c 0 --------------------------------------- package symbio.jobs.businessObjects; import ...

31. Newbie: Querying one side of many-to-many relationship    forum.hibernate.org

I'm surprised there is no response to this - at least an RTFM :-) Seems to me like it would be pretty straightforward for any reasonably-experienced Hibernater to answer - an easy credit point. Did I do a poor job of phrasing the question, or violate some unwritten rule of Hibernate etiquette? ;-) Eric

32. One-to-many relationship causes "Could not find a gette    forum.hibernate.org

I've used the Hibernate reverse engineering tool to generate mappings and java code for an existing underlying database (schema cannot be changed) but when I attempt to load the HAR archive on my JBOSS server I get: 2006-09-26 10:32:57,619 DEBUG [org.hibernate.jmx.HibernateServiceMBean] Error was org.hibernate.PropertyNotFoundException: Could not find a getter for parentDocument in class com.sugarcrm.DocumentRevisions at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282) I have been banging my ...

33. Need Help in query a bi-directional many-to-one relationship    forum.hibernate.org

Item item = itemDAO.getItemByID(itemId); // loop thru in java code to find the amout = 10.0 Set itemBids = item.getBids(); for (Iterator iter = itemBids.iterator(); iter.hasNext();) { (Bid) element = (Bid) iter.next(); if (element.amount == 10.0) { // found .... .... } ...

34. Sorting a query with a self-referencing table relationship.    forum.hibernate.org

Hi, I have a Process object and table. This process table represents a tree-structure of Process objects with each one having a reference to the ID of the process' root process. What i would like to do is list all processes, ordered by the name of the root process. Something like this. select p from HibProcess p, HibProcess r where p.RootProcessID ...

35. Finding relationships    forum.hibernate.org

Hello I have a system which has entities modeled using hibernate. There are classes already available which represents the database entities. Now given a class is there a way to find out what are the classes related to this class? I want to do this programmatically. Is there a way to find other metadata information like the properties and which column ...

36. Hql query on more table with many to many relationship    forum.hibernate.org

Hi to everyone, i've this database scenario: i've this five table with this field on my db: - hib_person(id, firstName, lastName, email); - hib_firm(id, name, address); - hib_country(id, name); - hib_firm_person(person_id, firm_id); - hib_firm_country (firm_id, country_id) the hbm files are this: Person.hbm.xml: ...

37. Querying on a many-to-many relationship question    forum.hibernate.org

38. Criteria query with Many-to-one relationship    forum.hibernate.org

39. How do i find the relationship?    forum.hibernate.org

seqPkUsuario ...

40. find method for many-many relationship attempting update    forum.hibernate.org

Newbie Joined: Tue Apr 06, 2004 8:44 am Posts: 9 My many-to-many mapping is doing a mysterious update. I think that it's getting the data that I need on my query. Why would it try to do an update? I don't call an update here at all... Code: "from User as model " + "where model.userName = '" + user.getUserName() + ...

41. JPA - A Simple Query with Relationships    forums.oracle.com

SELECT DISTINCT p FROM Player p, IN(p.teams) t Data retrieved: All players who belong to a team. Description: The FROM clause declares two identification variables: p and t. The p variable represents the Player entity, and the t variable represents the related Team entity. The declaration for t references the previously declared p variable. The IN keyword signifies that teams is ...