Hi, the method doesn't get called. Is there maybe any logging I can enable to check why it isn't called? I use log4j.
Tom -----Oorspronkelijk bericht----- Van: Daniel Kulp [mailto:[email protected]] Verzonden: donderdag 10 september 2009 22:14 Aan: [email protected] CC: Tom Cassimon Onderwerp: Re: Problem with primary key in Persisted object list Strange. All I can suggest then is to set a breakpoint in the getId method to make sure it's called during writing. Dan On Thu September 10 2009 4:06:28 pm Tom Cassimon wrote: > Yes, > > It does have those methods: > > =============================== > > public Long getId() { > return id; > } > > public void setId(Long id) { > this.id = id; > } > > =============================== > > One other thing, I also have @OneToOne relationships in the same Object, > and they have the Id fields filled in. The problem only appears in > @OneToMany relations. > > Tom > > -----Oorspronkelijk bericht----- > Van: Daniel Kulp [mailto:[email protected]] > Verzonden: donderdag 10 september 2009 21:48 > Aan: [email protected] > CC: Tom Cassimon > Onderwerp: Re: Problem with primary key in Persisted object list > > > Does the "id" field have public getter and setter methods? Without > those, > > it wouldn't get serialized. > > Dan > > On Thu September 10 2009 3:19:12 pm Tom Cassimon wrote: > > Hi, > > > > I'm using the newest version 2.2.3. > > > > The First problem I noticed is when using @OneToMany relationships > > in entity classes I do not get the Id (on client side). > > > > Example class: > > > > === Part of Patient.java === > > > > . > > . > > . > > @JoinTable(name = "patient_document", joinColumns = {...@joincolumn(name = > > "patientId")}, inverseJoinColumns = {...@joincolumn(name = "documentId")}) > > @OneToMany(fetch=FetchType.LAZY) > > private List<Document> documentList; > > . > > > > ============================ > > > > === Part of Document.java === > > > > @Entity > > @Table(name = "document") > > public class Document implements Serializable { > > > > private static final long serialVersionUID = 1L; > > @Id > > @GeneratedValue(strategy = GenerationType.IDENTITY) > > @Basic(optional = false) > > @Column(name = "id") > > private Long id; > > . > > . > > . > > > > ============================= > > > > When I check on the server side, the id field is filled in > > with the id from the database. But when I check on the client > > side the id is "null". This poses a problem when I submit the > > Patient object back to the server. The First thing is because > > the Id fields are "null" it thinks they are new objects. I update > > this with the following code: > > > > //Process documents > > if (p.getDocumentList() != null) { > > for (Document d : p.getDocumentList()) { > > if (d.getId() == null) > > em.persist(d); > > else > > em.merge(d); > > } > > } > > > > //Finally process patient > > if (p.getId() == null) > > em.persist(p); > > else > > em.merge(p); > > > > Maybe I shouldn't do it this way, I'm not really sure this is good > > practice. As a result my database gets flooded with duplicate documents > > (with blob's in it) because the cleanup of Orphan's doesn't work > > properly. > > > But in the first place the documents should not be reinserted every > > time. > > > > The second problem appears on client side when I want to remove a > > document from a Patient, it always removes the first in the list, because > > all Id fields are "null". > > > > An other question I have is if it is possible to do lazy loading, I mean > > with this load the Document instance but without the byte[] (blob) > > loaded, I don't know if it is configurable or what is the best practice > > to accomplish this. > > > > -----Oorspronkelijk bericht----- > > Van: Benson Margulies [mailto:[email protected]] > > Verzonden: donderdag 10 september 2009 20:48 > > Aan: [email protected] > > Onderwerp: Re: Problem with primary key in Persisted object list > > > > I'm afraid that I can't follow the thread here, in part due to all the > > extra whitespace. > > > > What exactly is not happening? What version of CXF? How it is configured? > -- Daniel Kulp [email protected] http://www.dankulp.com/blog
