Ola Pessoal estou enfrentando problemas com o toplink , estou usando o que vem com NetBean 5.5.1, sempre fiz o mapeamento na mão mas dessa vez por questão de tempo usei o NetBeans, o problema é o seguinte:
Caused by: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST.
Aqui segue as minhas classes mapeadas:
Usuario
@Entity
@Table(name = "usuarios")
public class Usuario implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "usr_codigo", nullable = false)
private Integer usrCodigo;
@Column(name = "usr_data_cadastro", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date usrDataCadastro;
@Column(name = "usr_nome", nullable = false)
private String usrNome;
@Column(name = "usr_sobrenome", nullable = false)
private String usrSobrenome;
@Column(name = "usr_empresa", nullable = false)
private String usrEmpresa;
@Column(name = "usr_email")
private String usrEmail;
@Column(name = "usr_login", nullable = false)
private String usrLogin;
@Lob
@Column(name = "usr_senha", nullable = false)
private byte [] usrSenha;
@Column(name = "usr_status", nullable = false)
private int usrStatus;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "usuariosUsrCodigo")
private Collection<Anuncio> anuncioCollection;
@JoinColumn(name = "cidades_cid_codigo", referencedColumnName = "cid_codigo", insertable=false,updatable=false)
@ManyToOne
private Cidade cidades;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "usuario")
private Collection<UsuarioPropaganda> usuarioPropagandaCollection;
Cidade
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "cid_codigo", nullable = false)
private Integer cidCodigo;
@Column(name = "cid_nome", nullable = false)
private String cidNome;
@Column(name = "cid_estado", nullable = false)
private String cidEstado;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cidades")
private Collection<Usuario> usuarioCollection;
estou usando essas duas para fazer a inserção!