В принципе, можно было бы добавить геттер и отдавать программе значение с подменой, но это поле является ключом для другого, которое ManyToOne, поэтому такой путь не подходит.
If your table truly has no unique columns, then use all of the columns as the id. Typically when this occurs the data is read-only, so even if the table allows duplicate rows with the same values, the objects will be the same anyway, so it does not matter that JPA thinks they are the same object. The issue with allowing updates and deletes is that there is no way to uniquely identify the object's row, so all of the matching rows will be updated or deleted.
Строки с одинаковыми данными - однотипные события, каждое последующее гарантировано "перекрывает" предыдущее.как раз это тебе и нужно.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</exclusion>
</exclusions>
</dependency>
gift-certificates
, я так понимаю, это глобальный префикс для контроллера@GetMapping(params = {ParameterName.SORT_BY})
означает: вызови этот метод, когда урл выглядит как gift-certificates?sort_by
@GetMapping
- который отвечает за gift-certificates
, поскольку все параметры после знака вопроса опциональны.хочу внести домен, логин и пароль в application.properties
Как можно внести properties за jar?
Стоит ли бросать кастомные ошибки
меня в нем беспокоит только конкатенация строк
throw new ApiException(String.format("Vote with id %d is not in DB", voteId));
public ApiException(String format, Object... parameters) {
...
}
throw new ApiException("Vote with id %d is not in DB", voteId);
@RestController
@RequestMapping(produces = APPLICATION_JSON_UTF8_VALUE)
public class MyController {
@PostMapping("process-json")
@ResponseBody
public ResponseEntity<String> processJson(@RequestParam(value = "stringArray")List<String> stringArray) {
return process(stringArray);
}
}
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<mainClass>${application.mainClass}</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<configuration>
<executable>true</executable>
</configuration>