Closed
Description
Describe the bug
For Spring Boot Tools extension V1.50.0 on vscode)
When creating a interface that extends JpaRepository, it will throw an error saying "Expected Domain ID type is 'java.lang.String'vscode-spring-boot(DOMAIN_ID_FOR_REPOSITORY)". When I switch back to v1.49.0 the error is no longer there.
To Reproduce
- Create an entity with a composite key
- Create a repository interface that extends JpaRepository<T,ID>
Sample
package sample.entities;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "customer_account_relationship")
@IdClass(CustomerAccountId.class)
public class CustomerAccountRel implements Serializable, ErrorLoggable {
@Id
@NotNull
@Size(max = 20)
@Column(name = "acct_nbr", length = 20)
private String acct_nbr;
@Id
@Size(max = 50)
@Column(name = "customer_id", length = 50)
private String customerId;
@NotNull
@Size(max = 5)
@Column(name = "relation_code", length = 5)
private String relation_code;
public void setAcct_nbr(String acct_nbr) {
this.acct_nbr = StringUtils.truncate(acct_nbr, 20);
}
public void setCustomerId(String customerId) {
this.customerId = StringUtils.truncate(customerId, 50);
}
public void setRelation_code(String relation_code) {
this.relation_code = StringUtils.truncate(relation_code, 5);
}
@Override
public String getId() {
return customerId + " - " + acct_nbr;
}
}
package sample.entities;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomerAccountId implements Serializable {
private String acct_nbr;
private String customerId;
}
package sample.repositories;
import sample.entities.CustomerAccountId;
import sample.entities.CustomerAccountRel;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface CustomerAccountRelRepository
extends JpaRepository<CustomerAccountRel, CustomerAccountId> {
public List<CustomerAccountRel> findByCustomerId(String customerId);
}