Problemas com @ Annotation

8 respostas
fabiobufalari

Bom dia pessoal estou com um problem na annotation -->@org.hibernate.annotations.NaturalId
diz o seguinte cannot be resolved to a type, o detalhe que as outras annotations funciona direitinho.
sera que alguem pode me ajudar ? parece ser problemas de path mas nao estou conseguindo resolver.
obrigado.

package br.com.policiaMilitar.usuario;
import java.io.*;
import org.hibernate.*;
import javax.persistence.*;
import java.util.*;

@Entity
@Table(name="usuario")
public class Usuario {	
	@Id
	@GeneratedValue
	
	private Integer idUsuario;
	
	private String nome;
	@org.hibernate.annotations.NaturalId	
	private String email;
	
	private String senha;
	private String idioma;
	private boolean estatus;
	public Integer getIdUsuario() {
		return idUsuario;
	}
	public void setIdUsuario(Integer idUsuario) {
		this.idUsuario = idUsuario;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getSenha() {
		return senha;
	}
	public void setSenha(String senha) {
		this.senha = senha;
	}
	public String getIdioma() {
		return idioma;
	}
	public void setIdioma(String idioma) {
		this.idioma = idioma;
	}
	public boolean isEstatus() {
		return estatus;
	}
	public void setEstatus(boolean estatus) {
		this.estatus = estatus;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((email == null) ? 0 : email.hashCode());
		result = prime * result + (estatus ? 1231 : 1237);
		result = prime * result
				+ ((idUsuario == null) ? 0 : idUsuario.hashCode());
		result = prime * result + ((idioma == null) ? 0 : idioma.hashCode());
		result = prime * result + ((nome == null) ? 0 : nome.hashCode());
		result = prime * result + ((senha == null) ? 0 : senha.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Usuario other = (Usuario) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (estatus != other.estatus)
			return false;
		if (idUsuario == null) {
			if (other.idUsuario != null)
				return false;
		} else if (!idUsuario.equals(other.idUsuario))
			return false;
		if (idioma == null) {
			if (other.idioma != null)
				return false;
		} else if (!idioma.equals(other.idioma))
			return false;
		if (nome == null) {
			if (other.nome != null)
				return false;
		} else if (!nome.equals(other.nome))
			return false;
		if (senha == null) {
			if (other.senha != null)
				return false;
		} else if (!senha.equals(other.senha))
			return false;
		return true;
	}
	
	
	
}

8 Respostas

luxu

o erro diz q NÃO pode ser usado para akele tipo STRING…

fabiobufalari

certo isso eu entendi, mas preciso de resolver esse problemas por que uma videoaula que estou assistindo da certinho!
mas de q q forma obrigado.
Fábio Bufalari.

fabiobufalari

tem mais um detalhe percebi que quando vou fazer um import por exemplo:
import org.hibernate.SessionFactory detalhe só navega até hibernate ai só disponibiliza package e nao consigo fazer o import do sessionFactory.
por favor ajudem.
obrigado

tiagoafs

Poderia listar os .jar que voce adicionou ao project?

fabiobufalari

Estao ai muito Obrigado.

Web App Librarys
antlrworks-1.4.3
commons-beanutils-1.8.3
commons-collections-3.2.1
commons-digester3-3.2
commons-logging-1.1.1
dom4j-1.6.1
hibernate-3.0
hibernate-jpa-2.0-api-1.0.0.Final
javassist
javax.faces-2.1.7
jsf-api-2.0.9
jstl-api-1.2
jstl-impl-1.2
jta-1.0.1B
jta-1.1
mysql-connector-java-5.1.18-bin
slf4j-api-1.6.4
slf4j-simple-1.6.4

JRE System Library
alt-rt
alt-string
charsets
deploy
javaws
jce
jsse
management-agent
plugin
resources
rt

tiagoafs

Tente adicionar o .jar hibernate-commons-annotations-X.X.X.Final.jar!

C

Olá, nos campos de e-mail eu so utilizo a annotation @Email, conforme abaixo. Não serve para você ?

@Email(message="E-mail inválido")
    @Column(nullable=false,unique=true,length=60)
    private String email;
fabiobufalari

opa ai sim … agora resolveu !!! obrigado

Criado 26 de fevereiro de 2012
Ultima resposta 28 de fev. de 2012
Respostas 8
Participantes 4