@Transient não está ignorando atributo

2 respostas
LeoCBS

Fala pessoal,

Tenho um atributo @Transient na minha classe Entity, porem quando faço um select.. da erro que a coluna não existe na base.. mais ela não existe mesmo.. o atributo é transient

Alguma dica galera?

Muito Obrigado pela ajuda!

Entity:
@Transient
	public ArrayList<StreamedContent> fotosCarregadas = new ArrayList<StreamedContent>();

public ArrayList<StreamedContent> getFotosCarregadas() {
		return fotosCarregadas;
	}

	public void setFotosCarregadas(ArrayList<StreamedContent> fotosCarregadas) {
		this.fotosCarregadas = fotosCarregadas;
	}
Erro:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'lugar0_.fotosCarregadas' in 'field list'

2 Respostas

R

Olá LeoCBS,

Eu posso estar errado, mas não se pode associar um relacionamento transient para coleções.
O mais correto pra mim seria um relacionamento parecido conforme o codigo abaixo:

@OneToMany(cascade = CascadeType.ALL, mappedBy = "campoTal", fetch=FetchType.LAZY)
public ArrayList<StreamedContent> fotosCarregadas = new ArrayList<StreamedContent>();  

public ArrayList<StreamedContent> getFotosCarregadas() {  
	return fotosCarregadas;  
}  

public void setFotosCarregadas(ArrayList<StreamedContent> fotosCarregadas) {  
	this.fotosCarregadas = fotosCarregadas;  
}
LeoCBS

Fala rafa, obrigado pela ajuda,

Eu consegui adicionar o meu atributo transient, coloquei a anotação no método get

@Transient public ArrayList<StreamedContent> getFotosCarregadas() { return fotosCarregadas; }

valeu!

abraço!

Criado 3 de abril de 2012
Ultima resposta 3 de abr. de 2012
Respostas 2
Participantes 2