object « Collection « JPA Q&A





1. How to overcome laziness when putting collection object into    forum.hibernate.org

I have an anoying problem when putting a persistent collection object into an object cache (jocache, to be exact) for faster later retrieval. Before putting it in the cache, I do use Hibernate.initialize(collection) to force eager loading. But when servlets later retrieve the collection and use the elements in it, many laziness exceptions thrown(ERROR net.sf.hibernate.proxy.LazyInitializer). I badly need someone's help. Any ...

2. Collections of any Object    forum.hibernate.org

Hello, I'm a part of a team that is trying to hibernate a severals classes. One of these classes is a class that has a Map of Objects. This Map represents a inderteminate number of Parameters. Due to the nature of the this Object this parameters can be from a String to a Integer or a Class type made by us. ...

3. Modifying the objects in collection    forum.hibernate.org

Hello, When I get the set from the persistent object the set has say 3 objects with ids 1,2,3. Now if I modify the collection and select only one of them say 2 it should reflect the database right ? I read the One Shot Delete and following the same method. HashSet hs = PO.getAphasiaSet(); hs.clear(); // Clearing the old values ...

4. Removing object from a collection doesn't seem to work    forum.hibernate.org

Author Message pitosalas Post subject: Removing object from a collection doesn't seem to work Posted: Fri Apr 30, 2004 8:20 am Beginner Joined: Tue Sep 30, 2003 4:16 pm Posts: 33 I am using Hibernete 2.1, with HSQLDB 1.7.1. Here is the code that is causing me a problem. It is intended simply to remove a certain child from ...

5. 1:n Assoc. change to collection of dep. objects    forum.hibernate.org

Hello, currently I've got the following mapping from table 'Model' to 'FaceLift' (1:n bi-directional association): [code] [/code] and [code]

6. reassociated object has dirty collection    forum.hibernate.org

7. HSQL how determine existence of an object in a collection    forum.hibernate.org

select count(a0_.id) as x0_0_ from A a0_ where (not exists( select a1_.id from A a1_ where (a0_.id = some( select ab.prop1, ab.prop2, ab.idA, ab.idB from ...

8. Mass object creation on collection operations.    forum.hibernate.org

I have following tables and corresponding classes with appropriate get/set methods for all fields. ITEMS ID ORDER ID ITEM_ID CUSTOMER_ID CUSTOMERS ID Code: class Item{ privater long id; ... private Set orders; /* hibernate.set table = "ORDER" cascade = "all-delete-orphan" lazy = "true" inverse = ...

9. How to add Object to a Collection without Retrieving first?    forum.hibernate.org

I have an object Group that has a Set of Item(s) (many-to-many). On the web form the user selects the Items he/she wants to add to the Group. The form reports the primary_key / ids of the items to add to the group. What is the best way to attach these items to the group? I don't want to have to ...





10. reassociated object has dirty collection    forum.hibernate.org

11. How to Return a Collection of Domain Objects?    forum.hibernate.org

I have a simple application using a jsp to presenting information. It works through Hibernate to a MySQL database. I am using Eclipse 3.1.1, MyEclipse workbench 4.1 MySQL 5.0, and Hibernate 3.0 The application is running on JBoss4.0.3SP1 This error is taking place when I take the results and try to place it in the session. What I want to know ...

12. How to generate a Collection of objects?    forum.hibernate.org

Newbie Joined: Wed May 17, 2006 11:52 am Posts: 5 I try to get the following: One user can have many Trainings. How can I achieve that? I think I need one-to-many or many-to-one. Whats the difference between the both? Here the SQL statements for creating the tables, so you know my structure: Code: create table saTaUser( ...

13. return collection as tuple object    forum.hibernate.org

Hello I have a two objects Doctor and Contact to doctor. Doctor can have more than one Contact. i have select like this select doctor,contactdoctor from Doctor doctor join doctor.contactdoctorSet contactdoctor where doctor.specialization in (:specialization) if doctor have two contacts it returns two rows like this : [doctor],[contact1] [doctor],[contact2] is any way how it can return collection of contacts as one ...

14. Collections of dependent objects    forum.hibernate.org

Hibernate version: 3.2 Hi, in section 8.2 (Collections of dependent objects) we can see: My question is: can i define an unique-key fomed by the "id" and the "initial" columns on the join table "some_names"? I've tried with no luck: ...

15. Removing objects that are contained in dfferents collections    forum.hibernate.org

[b]Hibernate version:3.1.3[/b] Hello all. I've persistent objects that are contained in different collections, also this objects can be retrieved independently with its DAO. I saw in the Hibernate session that the same java object is in the differents collections that contain it. But when I delete this object with the DAO, It isn't automatically remove from the collections!!!, Why Hibernate behave ...

16. Moving Object from One Collection to Another    forum.hibernate.org

Newbie Joined: Fri Sep 29, 2006 12:42 pm Posts: 4 Moving an object from one container to another is a very common maneuver (think cut-and-paste). I have a situation where i would like to use 'cascade="all-delete-orphan"'. This works just fine until i try to move an object from one collection to another, at which time i receive an exception stating "deleted ...





17. Removing a hibernate object from a collection    forum.hibernate.org

Newbie Joined: Mon Jul 23, 2007 11:58 am Posts: 15 Location: New Jersey I need help with what I think is a simple problem.... I have entities that can exist in three different states: NEW, OPEN and PROCESSED. I have named queries setup to retrieve this entities and place them in the appropriate List depending on their state. Now similar to ...

18. Removing object from collection    forum.hibernate.org

Hi all, this is probably easy but I can't work it out. I have the following mapping: Code: ...

19. Help: Storing one object in two collections    forum.hibernate.org

Hi folks, Currently I'm trying to store one element/object in two collections. According to the generated database schema this should work just fine. However, if I don't reset the id of my object to null, it does not work. There must be a way to 'store' exactly the same object within two collections ... Ideas? @Entity public class Candle implements Comparable ...

20. How to identify the problematic object of a collection of ob    forum.hibernate.org

I'm using Spring 2.0 and Hibernate 3.1.2. If I try to insert/update a collection of object by using getHibernateTemplate().saveOrUpdateAll(col); once there's an object with error, the exception thrown by Hibernate seems not having the information of with object causing the problem. That makes debug and trace hard to be done. Therefore, any method to allow easy identification? If I loop the ...

21. How to Create a Derived Collection of Objects    forum.hibernate.org

Newbie Joined: Tue Feb 26, 2008 1:17 pm Posts: 9 Hi all. I am trying to create a Set of objects without having an explicit foreign key. I have tried several things, but I am not making the connection. I have a database schema PARTY -> ORDERS -> ORDER_ITEMS -> REGISTRATIONS, with each subsequent table having a foreign key relationship back ...

22. Removing an object from a collection (many-to-many)    forum.hibernate.org

I have two classes: User and Photo and a unidirectional many-to-many relationship between then: @Entity @Table(name="USER") public class User { private Collection favouritePhotos = new ArrayList(); ... @ManyToMany(cascade={ CascadeType.ALL}) @JoinTable(name = "FAVOURITE_PHOTOS", joinColumns = @JoinColumn(name = "USER_ID"), inverseJoinColumns = @JoinColumn(name = "PHOTO_ID")) public Collection getFavouritePhotos() { return favouritePhotos; } } @Entity @Table(name="PHOTO") public class Photo { } In my spring service ...

23. 3.3.0 - Merge Object with collection of Immutable Objs    forum.hibernate.org

Hibernate Version: 3.3.0 When I merge an object which contains a collection of objects which are immutable (mutable=false) I get an exception: Caused by: java.lang.Throwable: Merged entity does not have status set to MANAGED; EntityEntry[ca.gc.csc_scc.model.bean.offender.purchase.Tax#10](READ_ONLY) status=READ_ONLY at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:97) at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692) at ca.gc.csc_scc.model.impl.dao.OffenderEffectDAO.savePurchaseOrder(OffenderEffectDAO.java:792) at ca.gc.csc_scc.model.impl.service.OffenderEffectServiceImpl.savePurchaseOrder(OffenderEffectServiceImpl.java:445) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at ca.gc.csc_scc.model.util.ServiceFacadeInvocationHandler.invoke(ServiceFacadeInvocationHandler.java:118) ... 27 ...

24. How to avoid defining Collections inside a Transfer Object    forum.hibernate.org

Hi guys, I have a class called Customer. To make a one-to-many relationship between this Customer and his accounts (identified by Account class), I can define a Set/Map/List type property called accounts inside the Customer class and make the necessary mappings inside the .hbm.xml corresponding to Customer and Account classes. I would like to know if I can avoid defining these ...

25. Objects are Duplicated in Collection    forum.hibernate.org

HI , I have problem sessionFactory.getCurrentSession().createSQLQuery( query).addEntity(PhysicalItemVerificationViewBean.class).list() ; it returns list but the list contains duplicated rows means same records multiple times . i have override equals and hashcode in bean class but still getting same records .if i use set instead of list some records are missing . Can anybody help me ASAP Thanks in advance Naresh Bahety

26. setting collection does not remove the old objects    forum.hibernate.org

Hello, I'm using hibernate 3.3.1 GA version. This is my use case. I have a parent with child objects. My first call to the server returns the parent with all the child objects. The client then performs some operation and return new set of child objects. My DAO code basically reconstructs the child and set all these incoming child objects. The ...

27. Model a Collection as a Domain Object?    forum.hibernate.org

Hello, I've searched around but can't seem to find an answer to what I assume is a common situation. In many cases, I have a relationship between entities that involves a collection, say Site, Page, and PageElement, where Site has a collection (Set) of Page instances, and a Page has a Set of PageElement instances. What I'd like to do is ...