Item « Map « JPA Q&A

1. Mapping items-itemtags-tags tables with nhibernate

Lets say i have this database design:



And i want to map it to the following class
class Item

2. HQL: order all items by a specific item in its map

I am quite new to Hibernate and currently struggling a bit with HQL. I have the following mapping and would like to get all "Industry" entities ordered by the "translation" for ...

3. JPQL for Entities with No Items in ManyToMany Relationship

Simple JPA/JPQL question. I have an entity with a ManyToMany relationship:

public class Employee {      

4. How to count total items in @ManyToMany

I got my model

public class Comic implements Serializable {

@Basic(optional = false)
@Column(name = "id")
private int id;

private Set<User> owners;

(lots of blah blah blah)    
and I want to query for total ...

5. Hibernate: How to select a single item based on a foreign key column that is part of an association mapping?

Hullo, So... I have the following objects:

public class Person {
   // some other getters/setters omitted.
   void setAddress(Address addy) {
       // omitted

6. How to delete a ManyToMany item using JPQL?

I have two models, say :

BlogPost(title, message)
Both have a ManyToMany relationship defined. Using JPQL, I delete a list of BlogPost with this query:
DELETE FROM BlogPost b WHERE b IN :list
(:list is a ...

7. hibernate @Any mapping, can't fetch the "any" item

Using hibernate @Any mapping to map multiple entities in the same, I haven't be able to build a request to fetch all the objects of a specific class. Hibernate doesn't seem to ...

8. Hibernate - removing item from collection

I wanted to clarify an assumption that I have made, regarding the functionality of Hibernate. Assume I have a Class of A's with a @OneToMany mapping with B's. These ...

9. How Filter by the number of items in child collection?

Hi there. I want to create a filter that selects items with his child items greater than some value, ie. Invoice, have 'n' Invoice-Items, i want select all the Invoices where his Invoice-Items count is greater than some value, I dont wanna do it with simple code after a query is maded, because I need make a paginated request. Thanks.

10. How to map a view of non-unique items?

11. mapped collection contains 100000 items but query returned 5

Hibernate version:2.1.6 Below is a System.out and stack trace that I added to the set method of a mapped class which takes a collection. Note the size of the List set into my object is 100000 even though the generated sql only returns some 15 rows. I cannot see anything abnormal in the debug statements. Any suggestions would be appreciated. [java] ...

12. Regarding mapping collections and adding a collection item

Hibernate version: 2/3 with cascade="all" In general one-to-many mapping situation such as this: "An Order has Many OrderItems" I have Order and OrderItem classes mapped such that I can do: orderObject.getOrderItems(); to retrieve all the OrderItems associated with that Order. and if I wanna add an OrderItem Object to that Order, then I can do: orderObject.getOrderItems().add( aNewOrderItem ); where aNewOrderItem is ...

13. How to map in one class 2 collections of the same ITEM class

Try to design your database like below :- Item :- itemId(p.k.) itemName Person personId(p.k.) item1(F.k.)-->Item item2(F.k.)-->Item That means your pojos for above Two Tables will be like below:- public class Item { private long itemId; private String itemName; // setter getter of all attributes } public class Person { private long personId; private Item item1; private Item item2; // setter getter ...

14. HQL: order all items by a specific item in its map