I have a problem with @Autowired and my JpaReposytory class when I try to build the project, the problem appears here.

This is my Jpa Repository class.

```
public interface IJpaRepositoryLivrariaDAO extends JpaRepository<EntidadeDominio, Long> {
    List<Cliente> findByCliente(Cliente cliente); // whem I put this line of code I've get the exeption below                                           
}

```

DAO implementation

```
@Repository
public class ClienteDAO implements IDAO {

    @Autowired
    List<Cliente> cliente;

    @Autowired
    IJpaRepositoryLivrariaDAO jpaRepositoryLivraria;

    @Override
    public void consultar(ModelMap modelMap) {

        Cliente c = (Cliente) modelMap.get("object");

        modelMap.addAttribute("object", jpaRepositoryLivraria
            .findByCliente(c));

}

```

the exception

> 
> 2017-10-10 21:18:58.524 WARN 4000 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt:
> 
> 
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'alterarCommand': Unsatisfied dependency expressed through field 'fachada';
> 
> 
> nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fachada': Injection of resource dependencies failed;
> 
> 
> nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clienteDAO': Unsatisfied dependency expressed through field 'jpaRepositoryLivraria';
> 
> 
> nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IJpaRepositoryLivrariaDAO': Invocation of init method failed;
> 
> 
> nested exception is org.springframework.data.mapping.PropertyReferenceException: No property cliente found for type Cliente!
> 
> 
> 

correct me if I was wrong, the problem is that I do not have the client for my list of Client or something like that

List findByCliente(Cliente cliente);

Thank you in advance for the help.

**UPDATE 1.**

Allright, based on the answers I made a few changes, trying to make the code works.

first, if I put one atribute Cliente in EntidadeDominio it will mess my database, so I have created a new JPARepository trying to make the code more simple to understand and execute

```
public interface IJpaRepositoryClienteDAO extends JpaRepository<Cliente, Long> {

    // I don't know the best way to use @Query, what I'm trying to do here
    // is to select * from Cliente where any of the clients 
    // atributes matches with their corresponding columns

    @Query("select c from Cliente c where c like %?1")
    List<Cliente> findByCliente(Cliente cliente);

}

```

and then call this method in

```
public class ClienteDAO 

    @Autowired
    IJpaRepositoryClienteDAO jpaRepositoryCliente;

    public void consultar(ModelMap modelMap) {

        Cliente c = (Cliente) modelMap.get("object");

        modelMap.remove("object");
        modelMap.remove("cliente");

        modelMap.addAttribute("object", jpaRepositoryLivraria.findByCliente(c));
    }
}

```

and here is my Cliente class and his binded classes for better undestanding

```
@Entity
@Component
@DiscriminatorValue("Cliente")
public class Cliente extends EntidadeDominio {

    @Embedded
    private Genero genero;
    private boolean ativo;

    @OneToMany(mappedBy = "cliente", targetEntity = CartaoCredito.class, cascade = CascadeType.ALL, orphanRemoval = true)
    private List<CartaoCredito> cartaoCredito = new ArrayList<>();

    @OneToMany(mappedBy = "cliente", targetEntity = Endereco.class, cascade = CascadeType.ALL, orphanRemoval = true)
    private List<Endereco> endereco = new ArrayList<>();
}

@Entity
@Component
public class CartaoCredito {

    @Id
    @GeneratedValue( strategy=GenerationType.AUTO )
    private long id_cartao_credito;
    private String numero;
    private String nomeCartao;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_cliente")
    private Cliente cliente;
}

@Entity
@Component
public class Endereco {

    @Id
    @GeneratedValue
    private Long id_endereco;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_cliente")
    private Cliente cliente;
}

```

doing this changes the code works, the problema now is tha i'm getting this error

> 
> java.lang.IllegalArgumentException: Parameter value [%com.les.livraria.dominio.cliente.Cliente@1a1147e] did not match expected type [com.les.livraria.dominio.cliente.Cliente (n/a)]
> 
> 
> 

the object is being sent correctly in my ClienteDAO class

```
modelMap.addAttribute("object", jpaRepositoryLivraria.findByCliente(c));

```

Well, now I'm going to track this error to see what is the source problem, if anyone have any ideias about how to handle this I'll be very gratefull, for now thank you very much.