I have implemented own class for representing of database vector data based on UserType class.
My example:
class MyVectorType implements UserType {
@Override
    public int[] sqlTypes() {
        return new int[] { Types.ARRAY };
    }
};
@Entity
@Table("MY_ENTITY")
public class MyEntity {
    private MyVectorType myVectorType;
}
However this class cannot be used in testing with h2 dialect ie. in memory database. There is error: No Dialect mapping for JDBC type: 2003.
Therefore I would like to exclude this entity (inc. repository) from testing but this does not work:
@SpringBootApplication
@ComponentScan(excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
                MyEntity.class, MyEntityRepository.class})
})
public class ApiApplication {
    public static void main(String[] args) {
        SpringApplication.run(ApiApplication.class, args);
    }
}
What is wrong or is there any best practice solving this problem?
EDIT 1: fixed examples - added correct entity and repository
SOLUTION 1: I think that the only possible solution for this moment is move entity classes (which needs to be excluded) to other package. Then set @EntityScan to scan just non-excluded package. Exclude filters in ComponentScan seems to work only in case of @Component classes, not @Entity. However this is not absolutely best practice to solve this problem.
Just define it as a @MockBean so the real implementation of your repository will be replaced by a functionless mock in your tests:
@MockBean
private MyVectorRepositoryType vectorRepository;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With