I have a table in the SQL database that has duplicate entries (which means I can not make a Composite Key) and no primary key.
I want to be able to retrieve all entries which match a certain column, accountRef.
In short, I'd like to execute the following query:
SELECT * from table where accountRef='xyz'
where 'xyz' would be a user input.
The issue I'm facing is is that using @Entity doesn't allow me to not specify IDs. Is there a way I can get around that? Here is my code BasicAccountAudit.java
@XmlRootElement
@Entity
//@Embeddable
@Table(name = "tb_Account_History", schema="dbo")
public class BasicAccountAudit implements Serializable{
private String accountRef;
private String client;
//getters and setters
BasicAccountAuditRepository.java
@Repository
public interface BasicAccountAuditRepository extends CrudRepository<BasicAccountAudit, Integer> {
List<BasicAccountAudit> findAll();
List<BasicAccountAudit> findByAccountRef(String accountRef);
}
What I've tried
I tried using @Embeddable but it gives me this error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'basicAccountController': Unsatisfied dependency expressed through method 'setBasicAccountDao' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'basicAccountDaoImpl': Unsatisfied dependency expressed through method 'setBasicAccountAuditRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BasicAccountAuditRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: