collection « Data Type « JPA Q&A





1. How can I create a hibernate collection that will be re-read every time I request it?    stackoverflow.com

I have an entity that has a state table associated with it. The state table is managed by another process, and contains a list of objects that my business logic ...

2. Null vs empty collections in Hibernate    stackoverflow.com

Say I have the following Hibernate-mapped class:

public class ClassA {       
   @OneToMany(fetch=EAGER)
   private List<ClassB> bList;
}
When I read an object of ClassA ...

3. Collection.contains(Enum.Value) in HQL?    stackoverflow.com

I'm a little confused about how to do something in HQL. So let's say I have a class Foo that I'm persisting in hibernate. It contains a set of enum values, like ...

4. Why my equals method won't work?    stackoverflow.com

assertEquals(def.getMengs(), exp.getMengs());
fails, reporting: expected: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> but was: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> Indeed, through the debugger I see that ...

5. Hibernate returns null unitilzed Collection    stackoverflow.com

I have two tables, users and images which need to be joined. there is exactly one user row in the users table to many images in the images table. In my users ...

6. How does one write a Hibernate "UserType" where the type has a collection in it?    stackoverflow.com

I have a Validity object which contains two dates, start and end. I have a UserType that I've written for this so that I can simplify the hibernate mappings for ...

7. Comparing two collections of enums with Hibernate or SQL    stackoverflow.com

I have an entity 'Parent' which has a Set of enums

private Set<MyEnum> myEnums = EnumSet.noneOf(MyEnum.class);

    @CollectionOfElements(targetElement=MyEnum.class)
    @JoinTable
        (name="PARENT_MY_ENUM",
 ...

8. How to store a Collection of Dates in Hibernate    stackoverflow.com

If I have the following field in a JPA2 @Entity:

List<Date> associatedDates;
How do I get JPA2 to persist this field? @OneToMany doesn't seem to work. Is JPA2's @ElementCollection the best way to go? If ...

9. JPA2 equivalent for Hibernate collection cache?    stackoverflow.com

With Hibernate a collection would be cached as follows:

class Bar {    
  ...    
  @OneToMany
  @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
  private Collection<Foo> foos;   ...





11. UserType containing a collection    forum.hibernate.org

Hi, I have mapped a User entity containing an Address, mapped as a UserType instead of a component (what you would normally do). Code: ...

12. null values in collection    forum.hibernate.org

Hello I have a Size Chart object with multiple Size Value associated with it. In case you're wondering, a Size Chart might be "dress sizes" and its associated Size Values might be "small", "medium", and "large". When I retrieve the object from Hibernate, the list of size charts contains a null value. I turned on debug_sql and executed the SELECT statement. ...

13. How to supply an Array or Collection to a named filter?    forum.hibernate.org

I'm trying to figure out how to do this too, so if anyone knows please post it! Most of the things I have tried ended with hibernate blowing up saying "Undefined filter parameter" but if I pack up an ArrayList an pass it into .setParameter() and define the type as "java.util.ArrayList" in the filter-def it doesn't blow up but it doesn't ...

14. Setting empty collections to null when retrieving    forum.hibernate.org

I am working with a number of different parent/child tables which I have successfully mapped as sets in hibernate. My application works beautifully except that Session.get creates zero-element sets when there are no rows in the child tables. Unfortunately, my application requires that in such circumstances the collections be set to null instead. How can I accomplish this? I apologize in ...

15. Equals method and collections    forum.hibernate.org

(snip) ses.addPhoneNumber("+33 123456789 (Me)"); ses.addPhoneNumber("+33 123456789 (You)"); ses.addPhoneNumber("+33 123456789 (Other)"); assertEquals(ses.getEmails().size(),2); (snip) ...

16. Collection initialized with extra null entry at beginning    forum.hibernate.org

Author Message rnmixon Post subject: Collection initialized with extra null entry at beginning Posted: Mon Mar 14, 2005 1:30 am Beginner Joined: Tue Sep 09, 2003 5:20 pm Posts: 43 For some reason I'm getting an extra entry in a collection when it is initialized (hydrated) from the database. In the same transaction I add all of the collection ...





17. problem with a transient collection    forum.hibernate.org

I have two classes A and B. the A class has a collection of B instances. I'm using the following tag in the A class mapping. I'm using the following tag in the B class mapping. I'm executing a program in order to execute ...

18. Timestamp and dirty Collection    forum.hibernate.org

19. ORA-01722: invalid number while initializing a collection    forum.hibernate.org

I am having this problem while initializing a collection. At first i thought it was a driver problem, but I continue to receive the same error after trying DataAccess and other comercial drivers. I moved my data to mySQL and it worked fine. Problem is, i need to work on Oracle... I guess it is related to the dialect I am ...

20. Setting Lazy Collections to NULL (Macromedia Flex Gateway)    forum.hibernate.org

I am implementing a project that uses Macromedia Flex and Hibernate. First, let me start by saying I don't want to disable lazy loading! What I want is to disable Hibernate from putting "Hibernate Collections" in my objects and instead place "null". I need this because the "Hibernate Collections" will confuse the Flex Gateway. If the collections are placed as "null", ...

21. hibernate filter on collection for max date    forum.hibernate.org

22. usertype and collection.size=0    forum.hibernate.org

23. A non-collection with a WHERE condition (or equivalent)??    forum.hibernate.org

Hibernate version:3 I've studied up but can't seem to find a way to deal with this (possibly unorthodox) situation: I have a mySQL database that stores 'text elements' which is to say various and sundry items of text which are related to other entities (a simple example would be model #, headline, multiple bullet copy points etc. for a product) Anyway, ...

24. NULL objects in collection    forum.hibernate.org

Newbie Joined: Thu Feb 19, 2004 10:25 pm Posts: 16 Need help with Hibernate? Read this first: http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: 3.1.2 Mapping documents:

25. Problem with simple Collection of Strings    forum.hibernate.org

I am attempting to implement the following. class ChildClass extends SuperClass { Set set; //contains strings } The super class had an id with generator native. The child class is using joined-subclass and has I am holding the set of strings in the child class like so It ...

26. net.sf.hibernate.collection.Set.equals() isn't reflexive    forum.hibernate.org

Hibernate version: 2.1.6 I have 2 instances of the same object recreated via Hiberante. Each has a Set of children objects and the sets aren't comparing equals, even though they should. More specifically, they compare equals() one diretion, but not the other, which violates equals() reflexive requirement. I'm pretty positive its in the hibernate Set implementation, though it seems hard to ...

27. Null Collections    forum.hibernate.org

Is there a way to get a collection mapped in hibernate to load a null value instead of an empty collection if there is no data for the collection in the database? From the example below there is no data for the keywords list. I would like the PortletInfoImpl created by hibernate to set null for the keywords property instead of ...

28. Part-time Collection in Object    forum.hibernate.org

I've got an interesting problem I hope someone can help me out with. I have an object that exists in two different locations simultaneously. The "home" object consists of only the base object (BasicItem, in this case). The "remote" object is identical except that it may contain a collection of override objects. Occasionally, the home objects are pushed to the remote ...

29. UserType containing collections    forum.hibernate.org

Hibernate version: 3.2.4sp1 I am attempting to use a CompositeUserType to define a polymorphic value type association as suggested by numerous posts. My value type is a bit unusual (although not considered exotic) in that it has a many valued association to another value type. A -> C <> ->* E In this diagram, entity A has a component C ...

30. Manipulation of null collection in many-to-many    forum.hibernate.org

Newbie Joined: Wed Feb 06, 2008 5:42 am Posts: 1 Hibernate version:3.2.0 Entity: @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Table(name = "partner", catalog = "partner", uniqueConstraints = {}) public class PartnerPartner extends PartnerResource { /** * */ private static final long serialVersionUID = 1L; private Set sites = new HashSet( 0 ); private PartnerOrganization organization; private PartnerPartnerContact partnerContact; private PartnerPartnerPayment partnerPayment; private Set categories ...

31. the retrieved collection is null    forum.hibernate.org

Author Message Raghda Post subject: the retrieved collection is null Posted: Wed Feb 18, 2009 1:28 am Newbie Joined: Sun Feb 08, 2009 4:33 am Posts: 8 Hi every body , I m new to hibernate and i have a problem in loading a collection from the database I have user class Code: package helper; import java.util.HashSet; import java.util.Set; ...

32. JPA read is forcing item into collection a second time.    forum.hibernate.org

I'm doing some ETL work, moving users and groups from an app-specific db to a share-able user/group/login facility. Unfortunately some user's emails are duplicated in the source. I'm keeping a HashSet of all emails and user names. With each new incoming record I check the caches for the name or email (adding if not found). If I have a cache hit, ...

33. A collection of strings inside an object    forum.hibernate.org

LS, I am trying to include a collection of countries (strings) inside a Movie object. The countries of origin strings are in a seperate db table from the Movie data table. The two tables are associated via a link table, that has the ID's of the parent Movie (one) and child countries (many). My questions: 1) Is it possible to read ...

34. Ununderstanding NULL value on collection    forum.hibernate.org

Hi, My last issue is the following : @Table(name = "A") @MappedSuperclass public Abstract class A { ... } @Entity @MappedSuperclass @Table(name = "B") @AccessType("field") public class B extends A { @Id @GeneratedValue protected long hId; @OneToMany(cascade = javax.persistence.CascadeType.ALL) @JoinTable(name = "B_ARGS") protected Map args = new HashMap(); ... } @Entity @Table(name = "C") @AccessType("field") public class C extends ...