users@glassfish.java.net

Re: JPA settings problem

From: <glassfish_at_javadesktop.org>
Date: Thu, 05 Jul 2007 11:43:49 PDT

Hi Cleiton,

Great, that you got it working!

As the relationship customer in Phone is mapped to a primary key column, it's defined when a phone instance is created, and can not be changed. Therefore, the customer field should be mapped read only, i.e.:

@Entity
@Table( name="CFGPHONE" )
@IdClass(PhonePk.class)
public class Phone extends VObject {
    @Id
    @Column(name="NIDPHONE", nullable = false)
    private Long id;
    
    @Id
    @Column(name="NIDCUST", nullable = false)
    private Long idCustomer;
       
    @NotNull
    @Column( name="CFGNPHONE" )
    private String number
    
    @NotNull
    @Column( name="CTYPEPHONE" )
    private String phoneType;
 
    @ManyToOne
    @JoinColumn(name = "NIDCUST", referencedColumnName = "NIDCUST", insertable = false, updatable = false)
    private Customer customer;
    ....
    ....
    ....
}
[Message sent by forum member 'mf125085' (mf125085)]

http://forums.java.net/jive/thread.jspa?messageID=225375