Oi pessoal, estou com um problema ao dar update em uma tabela, estou usando jpa e hibernate.
Eu consigo carregar os dados do banco e colocar no formulário para edição, mas ao clicar no botao de editar, ele gera tenho o famoso Lazy Inicialization Exception e nem acessa o método do bean.
Carreguei todos os relacionamentos lazy durante a transação com o banco de dados, não sei pq este erro ocorre.
A tabela cesta consigo editá-la, mas a tabela CategoriaTecnica não consigo editar, as duas tabelas tem um relacionamento 1 para um 1
Meus beans estão em ViewScope
Entidades
@Entity @Table(name = "cesta")
public class Cesta implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(unique = true, nullable = false)
private int id;
@Column(length = 150, nullable = false)
private String nome;
@Column(length = 1)
private String identificador;
@Lob
private String descricao;
@ElementCollection
@CollectionTable(name = "palavra_chave")
@Column(length=100)
private List<String> palavraChave = new ArrayList<String>();
// esta tabela que carrego e não consigo editar após carregá-la
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
private CategoriaTecnica categoriaTecnica = new CategoriaTecnica();
//getters e setters
Outra entidade
@Entity @Table(name = "categoria_tecnica")
public class CategoriaTecnica implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(unique = true, nullable = false)
private int id;
@Column(length = 50)
private String nomeTecnologia;
@Column(length = 50)
private String tipoTecnologia;
@ElementCollection
@CollectionTable(name = "formato")
private List<String> tipoFormato = new ArrayList<String>();
@OneToOne(mappedBy="categoriaTecnica", optional = false)
@JoinColumn(name = "idCesta")
private Cesta cesta;
Alguma proposta ou ideia pq isto esta acontecendo?
[]s