collection « Field « JPA Q&A

1. Is it mandatory to instantiate collection fields in JPA?

I was reading an article in which the author had implemented an Entity class like this:

public class Product {

 private List<Part> parts; // note the missing "= new ArrayList<Part>();"

 public ...

3. Calculated field for collection size

I want to have a getNumberOfDetails() in my master class that gives me the number of details without loading the details collection. What embarrass me with the filter is that it puts some hibernate code into my class. I am wondering why the "size" method of the collection proxy does not use a filter in the background to avoid loading the ...

4. Getting NULL in fields of join table of collection

Newbie Joined: Fri Jul 02, 2004 9:05 pm Posts: 10 Ok, here's what I'm seeing, as simple as I can: I have a ProfileObject.class which is linked by primary key "id" to a ProfileQuestion.class having primary key "qid" via an intermediate class ProfileProperty.class (Fields "pid" and "qid"). The three classes persist correctly to a Profiles table, Profile_Properties table and Profile_Questions table ...

6. Strange behaviour in collection update with generated fields

Newbie Joined: Tue Oct 24, 2006 5:24 am Posts: 2 I have a simple 3-record structure forming a classic n-m relation with an explicit intersection record: Code: {group} {person} \ / {GroupMember} The GroupMember record contains ...