cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Cassimon" <>
Subject RE: Problem with primary key in Persisted object list
Date Thu, 10 Sep 2009 19:19:12 GMT

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 ===

@JoinTable(name = "patient_document", joinColumns = {@JoinColumn(name =
"patientId")}, inverseJoinColumns = {@JoinColumn(name = "documentId")})
private List<Document> documentList;


=== Part of ===

@Table(name = "document")
public class Document implements Serializable {

    private static final long serialVersionUID = 1L;
    @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)

//Finally process patient
if (p.getId() == null)

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 [] 
Verzonden: donderdag 10 september 2009 20:48
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

What exactly is not happening? What version of CXF? How it is configured?

View raw message