users@glassfish.java.net

Re: _at_ManyToOne when Foreign Key is also Primary Key

From: <glassfish_at_javadesktop.org>
Date: Wed, 27 Oct 2010 13:07:09 PDT

Wow!

I tried put "insertable=false, updatable=false" in the fields they are FK and PK, so it worked as magic.
Thank you very much, ldemichiel!!


To the other people who had the same problem as I did, here comes the configuration:

public class [b]ClientCard[/b]{
@Id
@Column(name = "car_id_card")
private int idCard;

@Id
@Column(name = "cli_id_client")
private int idClient;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({_at_JoinColumn(name = "car_id_card", insertable=false, updatable=false)})
private Card card;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumns({_at_JoinColumn(name = "cli_id_client", insertable=false, updatable=false)})
private Client client;

}
[Message sent by forum member 'danilorocha']

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