ejb 3.0 - EJB and JPA and @OneToMany - Transaction too long? -
I am using EJB and JPA, and when I enter PhoneNumber
in the The phone number
is the attribute contact contact
, sometimes it takes several minutes to actually return data. It does not just call anybody, nothing or anything, whenever I call it again, it does not even appear, it seems magical.
In this way I access the data:
For (contact c: contactFacade.findAll ()) {System.out.print (c.getName () + "" + C.getSurname () + ":"); (PhoneNumber PN: c.getPhoneNumbers ()) for {System.out.print (pn.getNumber (+) + "(" + pn.getDescription () + ");"); }}
I am using mask session ejb generated by Netbeen (basic CRDude methods) it always prints the correct name and surname, sound and description only after a short time It is printed (it varies) by making it through the mask. I am guessing that there is something to do with the transaction, how can this be solved?
These are my JPA entities:
contact
@Entity Public Category Contact Device Serializable {Private Static Finals Long Serial VERSIONUID = 1L; @ Id @ Generated Values (strategy = generation type.eeto) Private long id; The name of the private string; Private string alias; @OneToMany (cascade = cascadetype.rmov, mapped = "contact") private collection & lt; PhoneNumber & gt; PhoneNumbers = New Arrestists & lt; PhoneNumber & gt; ();
Phononumber
@ Entity Applies Public Category Phone Numbers Serializable {Private Stable Last Long Serial VERSIONUID = 1L; @ Id @ Generated Values (strategy = generation type.eeto) Private long id; Private string number; Private string description; @ManyToOne () @ Zone column (name = "CONTACT_ID") Private contact contact;
You tried to use
fetch = Fetchtype .YAGER
for your OneToMany relationship?
Comments
Post a Comment