This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='utf-8'?> | |
<!DOCTYPE hibernate-configuration PUBLIC | |
"-//Hibernate/Hibernate Configuration DTD//EN" | |
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> | |
<hibernate-configuration> | |
<session-factory> | |
<property name="dialect">org.hibernate.dialect.PostgreSQL93Dialect</property> | |
<property name="connection.url">jdbc:postgresql://localhost:5432/***</property> | |
<property name="connection.driver_class">org.postgresql.Driver</property> | |
<property name="connection.username">***</property> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" | |
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"> | |
<persistence-unit name="first_main"> | |
<class>projects.mvc.first.entitys.Person</class> | |
<properties> | |
<property name="hibernate.archive.autodetection" value="class" /> | |
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL93Dialect" /> | |
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/hosp?currentSchema=myschema | |
spring.datasource.username=postgres | |
spring.datasource.password=Pikoff | |
spring.jpa.show-sql=true | |
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults: false | |
spring.jpa.properties.hibernate.connection.url:${spring.datasource.url} | |
spring.jpa.properties.hibernate.connection.username:${spring.datasource.username} | |
spring.jpa.properties.hibernate.connection.password:${spring.datasource.password} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ResponseBody | |
@ExceptionHandler(MethodArgumentNotValidException.class) | |
public ResponseEntity<List<ObjectError>> processValidationError(HttpServletRequest httpServletRequest, MethodArgumentNotValidException manve) throws MethodArgumentNotValidException { | |
return new ResponseEntity<>(manve.getBindingResult().getAllErrors(), HttpStatus.BAD_REQUEST); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ResponseBody | |
@ExceptionHandler(MethodArgumentNotValidException.class) | |
public ResponseEntity<StringBuilder> processValidationError(HttpServletRequest httpServletRequest, MethodArgumentNotValidException manve) throws MethodArgumentNotValidException { | |
StringBuilder response = new StringBuilder(); | |
for (ObjectError oe : manve.getBindingResult().getAllErrors() ) { | |
response.append(oe.getDefaultMessage() + "\n"); | |
} | |
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PersonDTO { | |
//TODO add отчество и дату рождения, высчитывать age | |
private Integer id; | |
@NotBlank | |
@Pattern(regexp = "[А-Я][а-я]+", message = "Имя должно состоять только из букв русского алфавита") | |
private String name; | |
@NotBlank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/testhosp | |
spring.datasource.username=postgres | |
spring.datasource.password=Pikoff | |
spring.flyway.locations=classpath:db/migration/test_migration | |
spring.flyway.schemas=myschema | |
spring.jpa.properties.hibernate.connection.url:${spring.datasource.url} | |
spring.jpa.properties.hibernate.connection.username:${spring.datasource.username} | |
spring.jpa.properties.hibernate.connection.password:${spring.datasource.password} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package projects.mvc.first; | |
import org.junit.Assert; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Qualifier; | |
import org.springframework.boot.test.context.SpringBootTest; | |
import org.springframework.test.context.TestPropertySource; | |
import org.springframework.test.context.junit4.SpringRunner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/hosp | |
spring.datasource.username=postgres | |
spring.datasource.password=Pikoff | |
spring.datasource.driver-class-name=org.postgresql.Driver | |
spring.flyway.schemas=myschema | |
spring.jpa.properties.hibernate.dialect: org.hibernate.dialect.PostgreSQL95Dialect | |
spring.jpa.properties.hibernate.connection.driver_class: org.postgresql.Driver | |
spring.jpa.show-sql=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package projects.mvc.first.repositorys; | |
import org.apache.log4j.Logger; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.stereotype.Repository; | |
import projects.mvc.first.entitys.Person; | |
import projects.mvc.first.exceptions.db.NoteNotFoundException; | |
import javax.persistence.EntityManager; | |
import javax.persistence.EntityTransaction; |
OlderNewer