|
| 1 | +/* |
| 2 | + * Copyright 2025 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package example.springdata.vector; |
| 17 | + |
| 18 | +import org.springframework.boot.CommandLineRunner; |
| 19 | +import org.springframework.boot.SpringApplication; |
| 20 | +import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 21 | +import org.springframework.stereotype.Component; |
| 22 | + |
| 23 | +@SpringBootApplication |
| 24 | +public class VectorApp { |
| 25 | + |
| 26 | + public static void main(String[] args) { |
| 27 | + SpringApplication.run(VectorApp.class, args); |
| 28 | + } |
| 29 | + |
| 30 | + @Component |
| 31 | + static class DbInitializer implements CommandLineRunner { |
| 32 | + |
| 33 | + private final CommentRepository repository; |
| 34 | + |
| 35 | + DbInitializer(CommentRepository repository) { |
| 36 | + this.repository = repository; |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public void run(String... args) { |
| 41 | + |
| 42 | + repository.deleteAll(); |
| 43 | + |
| 44 | + repository.save(new Comment("de", "comment 'one'", new float[]{0.1001f, 0.22345f, 0.33456f, 0.44567f, 0.55678f})); |
| 45 | + repository.save(new Comment("de", "comment 'two'", new float[]{0.2001f, 0.32345f, 0.43456f, 0.54567f, 0.65678f})); |
| 46 | + repository.save(new Comment("en", "comment 'three'", new float[]{0.9001f, 0.82345f, 0.73456f, 0.64567f, 0.55678f})); |
| 47 | + repository.save(new Comment("de", "comment 'four'", new float[]{0.9001f, 0.92345f, 0.93456f, 0.94567f, 0.95678f})); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
0 commit comments