Hi All,
I've had problem to map a composite key between a Customer class and Phone class in EJB3.
I mapped these classes like shown below and working fine without using EJB3. Therefore when I use these entities in EJB3 and try to retrieve a Customer, the aplication keep a loop until Glassfish turn off through protocol violation.
@Entity
@Table( name="CFGCUSTOM" )
@javax.persistence.SequenceGenerator(
name="SEQ_CUSTOM",
sequenceName="SEQ_CUSTO" )
public class Customer extends VObject {
@Id
@Column( name="NIDCUST" )
@GeneratedValue( strategy=GenerationType.SEQUENCE, generator="SEQ_CUSTO" )
private Long id;
@NotNull
@Column( name="CNAMECUST")
private String name;
@OneToMany( mappedBy="id.customer", cascade = { CascadeType.ALL }, fetch=FetchType.EAGER )
private Set<Phone> phones= new HashSet<Phone>();
....
....
....
}
@Entity
@Table( name="CFGPHONE" )
@AssociationOverride( name="id.customer", joinColumns = { @JoinColumn( name="NIDCUST" ) } )
public class Phone extends VObject {
@EmbeddedId private PhonePk id;
@NotNull
@Column( name="CFGNPHONE" )
private String number
@NotNull
@Column( name="CTYPEPHONE" )
private String phoneType;
....
....
....
}
@Embeddable
public class PhonePk implements Serializable {
@Column( name="NIDPHONE" )
private Long id;
@ManyToOne( fetch=FetchType.EAGER )
@JoinColumn( name="NIDCUST" )
private Customer customer;
....
....
....
}
I read these mappings aren't support in EJB3, but I'm not sure. Do anybody know how to solve it.
Thanks,
Cleiton
[Message sent by forum member 'cleitonls' (cleitonls)]
http://forums.java.net/jive/thread.jspa?messageID=224909