Problem « Collection « JPA Q&A





1. Problem updating collection using JPA    stackoverflow.com

I have an entity class Foo foo that contains Collection<Bar> bars. I've tried a variety of ways, but I'm unable to successfully update my collection. One attempt:

foo = em.find(key);
foo.getBars().clear();
foo.setBars(bars);
em.flush; ...

2. Problem with filtering a collection in hibernate    stackoverflow.com

I have a following data structures:

@Entity
@FilterDef(name="usageHistoryFilter", parameters=@ParamDef( name="updateDate", type="date" ))
@Table(name = "Services")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Service extends DBEntity {
    private Set<UsageHistory> usageHistorySet;

    @OneToMany(cascade = CascadeType.ALL, ...

3. Collection of superclass problem    forum.hibernate.org

4. Problem with multiple collections    forum.hibernate.org

Hi all, i'm new to hibernate ad i have a frustating problem that, i think, has a simple solution. I have an object with three collections like described by the mapping file below Code: ...

5. Extra Lazy Collection - IndexColumn problem    forum.hibernate.org

6. Problem initializing 2 lazy collections for one object    forum.hibernate.org

Author Message D10C Post subject: Problem initializing 2 lazy collections for one object Posted: Wed Oct 22, 2003 5:42 am Newbie Joined: Wed Oct 22, 2003 5:30 am Posts: 1 Exerpt from my mapping: Code: ...

7. Hibernate problem with collections in client/server app    forum.hibernate.org

Hello, Im building a client/server application using RMI and Hibernate in the server side. To save, delete and retrieve persistent objects I built a class on the server called ServerAcess with methods saveObject, deleteObject, retrieveAllObjects etc that can be accessed by clients via RMI. The objects are passed from client to server and vice-versa via Serialization. Example: public Set retrieveAllObjects(Class persistenteClass) ...

8. Problems initializing collection!?    forum.hibernate.org

I'm using Hibernate 2.1.1. I'm using "fetch" in the query to initialize the collection! I don't understand why is he giving me the following error: Code: ERROR: Failed to lazily initialize a collection - no Session net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no Session at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:213) at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:69) at net.sf.hibernate.collection.Set.toString(Set.java:219) ...

9. remove item of collection in parent problem    forum.hibernate.org

I load a parent with a collection of children from db. If I remove one of item from the collection and persist the parent object to db. The item which I removed are still in db. If I have create a Interceptor implementation and print out the collection on 'findDirty' method, the currentState & previousState on the collection are same. I ...





10. Lazy collection is having problems?    forum.hibernate.org

Hi all, I'm having problems with my lazy one-to-many relationships... I mark them as lazy="true" but when I load my parent, all my childs with lazy="true" are loaded too. I'm using 2.1.1 and tried also with 2.1.2 Is there something I am missing? Thanks in advance.

11. Problem persisting collections    forum.hibernate.org

Hi fellows. I'm facing a problem with collections. I got two collections, addresses of PersonAddress, and contactMeans of PersonContactMean, in a class called Person. First, I had only contactMeans in Person, and when I tried to saveOrUpdate a new instance of Person that had one or more contactMeans everything was ok. But after I created addresses field, same way I did ...

12. Problem with nested collections    forum.hibernate.org

Regular Joined: Fri Jul 16, 2004 3:04 pm Posts: 52 Location: Wiltshire UK Hi I wonder if anyone can help me please. I have a web application which I have just ported over from EJB2 CMP to Hibernate 2.1.4, I am using mySQL 3.23.38. I am having a problem with nested collections. The scenario follows ( & some code follows the ...

13. Problems with Collections    forum.hibernate.org

14. collection creation problem    forum.hibernate.org

Hi guys, I found the following code in the Hibernate reference manual is not working in Hibernate 2.1.6 Cat cat = new DomesticCat(); Cat kitten = new DomesticCat(); .... Set kittens = new HashSet(); kittens.add(kitten); cat.setKittens(kittens); session.save(cat); I traced SQL statement, and found that hibernate create SQL update statement rather than SQL insert statement. But if you delete "cat.setKittens(kittens);" statement, the ...

15. Problem scrolling objects with Collections    forum.hibernate.org

We're using Hibernate 2.1.6 and are butting into the following exception, which we suspect is related to scrolling (althoug we're still trying to isolate the bug): Code: Caused by: net.sf.hibernate.HibernateException: Found two representations of same collection: com.sample.Company.SiteSet at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2870) at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32) ...

16. [many to many and collection problem]    forum.hibernate.org





17. collection problem --- please help!    forum.hibernate.org

i got problem to persist parent and child. below is my mapping file and error message i got. Mapping documents:

18. Problem updating a collection    forum.hibernate.org

Hi, consider an object A that has a one-to-many collection of B objects. Usually when I set an entire collection to an object (A.setBs(set);) what it does is deleting all the items in the collection and adding the new ones, which generates a delete in sql that eliminates the records and then an insert that creates the new ones. The problem ...

19. Collections and join problems    forum.hibernate.org

Hello I am having difficulties with collections. My issue is that when I execute the named query down below I get both: Services with the initialised abo collections and for each abo a service object. Or explained differently, I have 1000 abo objects which are valid for a certian period of time and 100 services. When I fetch all services I ...

20. Problem with Collection Object    forum.hibernate.org

21. Problem exporting to XML for collection    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: Hibernate 3.0 Mapping documents: Code:

22. Help!a problem occurs when retrieving a collection    forum.hibernate.org

Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Please help me solve this problem. I recently participated in a project.I use hibernate as it is a very excellent option in handling persistence layer.However,I encountered a problem whcih has already bothered me for two days.Here is my problem: The project is developing an online test system.The database system I use ...

23. Problems trying to make a collection from 3 other tables    forum.hibernate.org

Hibernate version: 3ish Hi, I've been struggling on and off with this for months :( I've finally given in and decided to ask the experts :) I'm having big problems mapping an (inherited) DB. I've simplified the table names somewhat to avoid confusion but basically I have a 'Family' table and a Children table that has a key to the family ...

24. Problems Will Collection--Invalid Character in Generated SQL    forum.hibernate.org

I don't understand this one. It appears that something is going wrong with the SQL Generation: Stack Trace with SQL: 008:53:58,937 INFO [STDOUT] Hibernate: select _roles0_.role_id as role_id__, _roles0_.USER_PROFILE_ID as USER_PRO4___, _roles0_.role_id as role_id0_, _roles0_.role_type_id as role_typ2_0_, _roles0_.user_profile_id as user_pro3_0_ from ROLE _roles0_ where _roles0_.USER_PROFILE_ID=? 08:53:58,953 WARN [JDBCExceptionReporter] SQL Error: 911, SQLState: 42000 08:53:58,953 ERROR [JDBCExceptionReporter] ORA-00911: invalid character Mapping File: ...

25. Please help, Problem with collections    forum.hibernate.org

I have a huge problem with a collection (bag) in hibernate in a rather complex data-collector program using a database with more than a million data. So it is important only to load neccesary data through hibernate. Now to the problem: I have an energycase with a collection of subcases: A subcase ...

26. problem updating element in a collection..    forum.hibernate.org

====================== Order order = (Order) session.get(Order.class, new Long(1)); Iterator it = order.getItems().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); item.setInfo("hello world"); } tx.commit(); ====================== Exception occur [constriant violation of Item table primary key]. Instead of updating an ...

27. how to re-attach collection with session (evicted problem)    forum.hibernate.org

This seems like you are fighting the Hibernate management of objects. So lets start at the top: Why are you trying to lazy load a collection after you has disconnected it? Based on that reply, there are some options: 1.) Don't disconnect the object, use a managed session object (currentSession() rather than openSession). 2.) Apply a filter that closes the session ...

28. Problem with dereferenced collection    forum.hibernate.org

Newbie Joined: Wed Nov 02, 2005 12:50 pm Posts: 5 New to hibernate, and rather stumped. The problem occurs when querying existing objects via criteria and the referenced collection has more than 0 rows associated. I have read this: http://www.hibernate.org/264.html ans would say I understand why this is happening if it weren't for the fact that it is. Sorry if it ...

29. problem: reassociated object has dirty collection reference    forum.hibernate.org

[b]Hibernate version: 3.0.5[/b] I am trying to update an object in the database from an external source. I have an object A with a collection (set) of objects B. I have a file with updated state of the object A and its collection of objects B. I am doing the following: 1. creating a new A with [code] A a = ...

30. Problems with HQL and Collections    forum.hibernate.org

I have a problem trying to create a HQL using collection. I have this tables: Code: ac_company ---------- id: integer name: varchar(50) ac_group --------- id: integer name: varchar(50) ac_user ------- id: integer name: varchar(50) ac_comp_group ------------- comp_id: integer group_id: integer ac_user_group ------------- user_id: integer group_id: integer I have the respectives classes Company, Group and User. The mapping of the collections is ...

31. Problem removing item from collection and then saving    forum.hibernate.org

... ...

32. Collection of values update - problem    forum.hibernate.org

Hi all, I have the following mapping: Thus there is one class (Record) that is mapped from more db tables: records, record_images. I have problem with ...

33. Collections problem    forum.hibernate.org

Hi, I have some problems with a select query. I have the following classes Person { Set

addresses; } Addresses { Set accessRight; } AccessRight { Set members; } now I have a query that says: "select person.addresses from Person person where :user in (person.addresses.accessRight.members)"... However I get the output "could not resolve property: members of my.core.Addresses" - however, "members" is ...

34. Problem with collection elements not getting persisted    forum.hibernate.org

Author Message stevewickii Post subject: Problem with collection elements not getting persisted Posted: Fri Aug 04, 2006 5:42 pm Beginner Joined: Mon Apr 24, 2006 9:47 pm Posts: 33 Location: Kansas City, MO Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1.2 Mapping documents: Lead.hbm.xml, LeadLocation.hbm.xml Lead.hbm.xml Code:

35. Problem removing objects from a collection    forum.hibernate.org

Hibernate version: 3.1.3 Name and version of the database you are using: HSQLDB 1.8.1 I have a complex class with some collections of complex child objects and some collections of simple objects... like this public class Data { ... public List getApplicationSchemaInfo() { ... return applicationSchemaInfo; } public List getHierarchyLevelName() { return hierarchyLevelName; } ... } mapped like this:

36. problem accessing parent's collection    forum.hibernate.org

Hi there. I an newbie and i need some help. Concerning the Cat-DomesticCat example of the reference, i face this problem: Uppon trying to insert a new cat with a mother, i get the following error: "could not initialize a collection: [hibernate.Cat.kittens#1]" the error is generated when i try to add the new cat into the mother's kitten collection, by this ...

37. Initailizing collection problem    forum.hibernate.org

38. No PropertyTypeExtractor for type void (collections problem)    forum.hibernate.org

Using Hibernate 3.2, I get the following error: javax.persistence.PersistenceException: java.lang.IllegalArgumentException: No PropertyTypeExtractor available for type void After some debugging, I was able to narrow it down to the following method declaration that is inside an entity class: protected ArrayList splitEventTimes(Integer[][] eventTimes) The exception is thrown as well for the following declaration: protected ArrayList splitEventTimes(Integer[][] eventTimes) The exception is not thrown for ...

39. Collection update (merge) problem    forum.hibernate.org

Hi, Here is my problem description: 1) I am using JPA (EJB3.0) with Hibernate as JPA provider. I am using JDK 1.5, SJAS 9.1, Derby as a database and Hibernate 3.2.2. I am using container managed transactions. 2) I have class Child and class Parent. There is a unidirectional ManyToMany mapping from parent to child as shown below @Entity public class ...

40. Collection in Collection persisting problem    forum.hibernate.org

Newbie Joined: Tue Jul 31, 2007 8:37 am Posts: 12 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.2.4 SP1 Hello all! Sorry for my english at first. I have a legacy DB schema, and I'm not allowed to change anything. The scheme looks like that: Code: ...

41. Problem with collections and lazy mode    forum.hibernate.org

Hibernate version:3.1.3 Name and version of the database you are using:Oracle 10g I use a one-to-many association and I have got problem with lazy mode because the collection is loaded when I search for parents items. When I look for SQL queries, there is one query for parents and one for each result. I don't want to use fetch mode, I ...

42. Many-to-many collection problem    forum.hibernate.org

Hibernate version: 3.2.5.ga I have posted on this before. I got no replies, so I parked the issue and moved on but now I have to deal with it. Because of my limited Hibernate knowledge, I am not even really sure of what things to try anymore. Can someone shed some light on this problem for me? I have two Objects, ...

43. Problem : can't add new one after remove the old collection    forum.hibernate.org

Author Message Ken0716 Post subject: Problem : can't add new one after remove the old collection Posted: Wed Oct 24, 2007 8:30 am Newbie Joined: Wed Oct 24, 2007 6:55 am Posts: 4 hi, all, I'm a newbie of Hibernate framework. Now I have a problem with my code. In my design, I use parent-child relation to bind the ...

45. using collection interface problem.    forum.hibernate.org

46. Newbie - problem saving collections    forum.hibernate.org

Regular Joined: Tue Apr 10, 2007 10:02 am Posts: 50 I'm getting a hibernate mapping exception each time I try to save an entity that has collections... Here's the Java class... Code: public class ServiceEntry extends VersionedAliasTitledEntity { private static final long serialVersionUID = 3881126332255299362L; private String fShortDesc; private String fLongDesc; ...

47. EntityListner / Collection Problems    forum.hibernate.org

48. problem with duplicate references in collection    forum.hibernate.org

We have following situation: A Contract object with following (stripped) declaration: public class Contract{ private Long id; private Long claimId; private List contractObjects; ... getters & setters ... @OneToMany(fetch=FetchType.LAZY, mappedBy="contract") @Cascade({CascadeType.ALL, CascadeType.DELETE_ORPHAN}) @JoinColumn(name="CONTRACT_ID") public Set getContractObjects() { return contractObjects; } } A contract object is an abstract class with sub classes like ContractVehicle and ContractParty. But: there is a parent - ...

49. problem with dirty Collections in session.flush()    forum.hibernate.org

HI, I have a problem with dirty collections when I execute a session.flush I couldn't fixed this yet , Do you have a solution for this problem?? The stack is: collection Staff.orders was not processed by flush() I have identified the problem , y have viewed a possible solution but it didn't work. The solution was change every CollectionEntry to resolved, ...