Skip to content
Snippets Groups Projects
Commit bda3571c authored by Annika Geßmann's avatar Annika Geßmann
Browse files

working example with cat schema

parent 22a0c889
No related branches found
No related tags found
No related merge requests found
package thinkTogether.groupManagement.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import thinkTogether.groupManagement.model.Cat;
import thinkTogether.groupManagement.repo.CatRepository;
import java.util.List;
@RestController
public class CatRestController {
private final CatRepository catRepository;
public CatRestController(CatRepository catRepository) {
this.catRepository = catRepository;
}
@GetMapping("/cats")
public List<Cat> getAllCats() {
return catRepository.findAll();
}
}
package thinkTogether.groupManagement.model;
import javax.persistence.*;
@Entity
@Table(schema = "playground", name = "cat")
public class Cat {
@Id
@GeneratedValue
private Long id;
@Column(name = "name")
private String name;
public Cat() {
}
public Cat(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package thinkTogether.groupManagement.repo;
import org.springframework.data.repository.CrudRepository;
import thinkTogether.groupManagement.model.Cat;
import java.util.List;
public interface CatRepository extends CrudRepository<Cat, Long> {
public List<Cat> findAll();
}
spring.datasource.url=jdbc:mariadb://thinktogether.mariadb.database.azure.com:3306
spring.datasource.platform=mariaDB
spring.datasource.username=Nachtkind@thinktogether
spring.datasource.url=jdbc:mariadb://thinktogether.mariadb.database.azure.com:3306/playground
spring.datasource.username=Nachtkind
spring.datasource.password=!13072020VerteilteSysteme
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
# Keep the connection alive if idle for a long time (needed in production)
spring.datasource.testWhileIdle=true
#Hibernate Configuration
# Show or not log for each sql query
spring.jpa.show-sql=true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
#spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
## Keep the connection alive if idle for a long time (needed in production)
#spring.datasource.testWhileIdle=true
##Hibernate Configuration
## Show or not log for each sql query
#spring.jpa.show-sql=true
## Hibernate ddl auto (create, create-drop, update): with "update" the database
## schema will be automatically updated accordingly to java entities found in
## the project
#spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.validator.apply_to_ddl=false
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
# naming strategy
# Naming strategy
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jpa.open-in-view=false
spring.datasource.validationQuery=SELECT 1
#spring.jpa.properties.hibernate.validator.apply_to_ddl=false
## Allows Hibernate to generate SQL optimized for a particular DBMS
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
## naming strategy
## Naming strategy
#spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
#spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
#spring.jpa.open-in-view=false
#spring.datasource.validationQuery=SELECT 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment