collection « Entity « JPA Q&A





1. pitfalls of collections of entities in Hibernate    stackoverflow.com

OK, this is a follow-up question to this one, since I am really confused now. Suppose I have a one-to-many or many-to-many association between entities Person and Event such that a ...

2. Add new Entity to persisted Collection    stackoverflow.com

I've got to Tables related in one-to-many association: Product*1 - n*Inventory

@Entity
public class Product {
    // Identifier and properties ...

    @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) ...

3. JPA Best Practice to update an Entity with Collections    stackoverflow.com

I am using JPA in a Glassfish Container. I have the following Modell (not complete)

@Entity
public class Node {
    @Id
    private String serial;
    ...

4. direct lookup in contained collection of an entity in ORM(hibernate)    stackoverflow.com

Let us consider i have 2 classes A and B such that A -->(1..n) B . A "contains" B. In ORM terms i want A to be an entity and B ...

5. Entity intercepted when a collection element updated    forum.hibernate.org

Hi all. I need to know how can I set Hibernate (...) to achieve the following issue: I have a bidirectional (composition) one-to-many association (a.bs is a Set object and b.a is a A object). When I load "a" from DB and I update one of its "bs" I need Hiernate intercept A entity when saveOrUpdate A. Code: Code: public class ...

6. Collections of entities containing collections of entities    forum.hibernate.org

@Entity @Table(name = "t_order") public class Order implements Serializable { private static final long serialVersionUID = 8986089659809970850L; @Id @GeneratedValue @Column(name = "order_id") private Integer id; @Column(unique = true, nullable = false) private String orderNumber; @OneToMany(cascade = CascadeType.ALL, ...

7. How can I programmatically populate collections on an entity    forum.hibernate.org

I have a query where I get back millions of entities. I am doing calculations on each one and reducing the set down to thousands of entities. Now, I want to access a collection on each of those thousands of entities, but I am not sure how to performance optimize it. I looked for something like session.fetch(entities, "dataPointBag"); but I couldn't ...

8. Updating Entity with Collection    forum.hibernate.org

Author Message wheels979 Post subject: Updating Entity with Collection Posted: Wed Oct 13, 2010 3:49 pm Newbie Joined: Thu Aug 19, 2010 3:36 pm Posts: 3 Hi All, I am fairly new to Hibernate. I have what seems like a fairly simple question. I need to understand how to update an entity that has an association with another entity. ...

9. Filtering entities with collection of primitives    forum.hibernate.org

Hi guys, I have a problem using Hibernate. I'll try to explain everything as clear as possible, I hope someone can help me. Thanks! My entity class have a list of Long's as a property: public class Entity { private Long id; private List roles; } Mapping XML:





10. Future-dated entities and collection membership    forum.hibernate.org

Hi all, I'm working through a redesign of our system that will involve future-effective dating some entities. I am aware of using a filter for effective-date entity queries in general, and also the existence of Hibernate Envers (which I plan to use). But, in the case of a revision of an entity that's supposed to become effective in the future, wouldn't ...

11. Puzzling this on an Hibernate entity and its collection    forum.hibernate.org

Hello, I have a very puzzling thing happening around an Hibernate entity and its collection property. There is an entity LinkCategory which has a collection property of Link(s). Here is the Hibernate mapping: Code: ...

12. Passing entity collections remotely    forum.hibernate.org

I have an EJB with a method that returns a list of hibernate-persisted objects. These objects each have a Set relationship to a different entity. My EJB fetches them with: from Motd m left join fetch m.shards When calling this method remotely, I get an exception because the client can't load net.sf.hibernate.collection.Set. I thought I remember reading something somewhere about Hibernate ...

13. Collection without containing entity?    forum.hibernate.org

14. saving collections along with the owning entity    forum.hibernate.org

Hibernate version: 2.0

15. How to update collection entities via saveOrUpdateCopy    forum.hibernate.org

Class Person has list of Class House instances and X has a business key, where as y has "sequence" id. Suppose in one session, I save Person p calling saveOrUpdateCopy(p) with saving person's homes with cascade=all Then in another session, I created new Person instance with same identifier and with a new list of houses. Then I call saveOrUpdateCopy(p), it correctly ...

16. How to add ~none persistant entities to a collection    forum.hibernate.org

Hi all, am hoping you can help. I have a mapped entity.. for the sake of an example lets call it Customer. I have a database table called countries, and a mapping called country. I want to map a set that is a collection of all the records in the countries table of type country, but there would be no relationship ...





17. Determining index of entity in persistent collection    forum.hibernate.org

org.hibernate.QueryException: could not resolve property: index of: eg.Photo [select index(this) where this=?] at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37) at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1310) at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:280) at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:373) at org.hibernate.hql.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:114) at org.hibernate.hql.ast.tree.MethodNode.collectionProperty(MethodNode.java:95) at org.hibernate.hql.ast.tree.MethodNode.resolve(MethodNode.java:44) at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:842) at ...

18. Comparing an entity's collection with user input    forum.hibernate.org

19. Hibernate: Moving Entities Between Collections    forum.hibernate.org

Is it possible to move an entity from one collection to another? I have two top level entities A and B which both have one-to-many references to another entity C, which happens to have its own network of stuff below it. Cascade deletes are working fine - if I delete C, it and everything below it goes away. Also, if I ...

20. Simple persistence of Collection not related to any entity    forum.hibernate.org

Hi all, First, I'd like to thank you all for all the good practices and solutions Ive been able to find here. I am know facing a very simple problem and don't know which direction to take. I was not able to find anything helpful in the forum at this time. I would like to persist a simple collection of entities ...

21. entity collection is not returning every element    forum.hibernate.org

I have a simple entity that connects to 4 other tables as a OneToMany relationship. When I fetch these collections, the correct number of results is returned. However, every object in the list is the same (the first object in the list). Furthermore, the objects are the exact same object reference. Hibernate version: Not sure what exact version. I believe its ...

22. How to apply the same Filter on Entity X and Collection of X    forum.hibernate.org

Hi I am using Filters to enforce access rights but have encountered a duplicate-code problem. We have a @Filter "Access" specified in Entity ClassA and is specific to this particular entity. Another Entity ClassB has a Collection, but to enforce the same filter "Access" I will have to have the filter code from Entity ClassA duplicated in ClassB in relation to ...