Browse Source

entidades

master
Juanjo 1 year ago
parent
commit
d33ed5d3d6
7 changed files with 134 additions and 2 deletions
  1. +41
    -0
      src/main/java/es/fp/edu/conecta2/BDConfig.java
  2. +12
    -0
      src/main/java/es/fp/edu/conecta2/controladores/Controlador01.java
  3. +33
    -0
      src/main/java/es/fp/edu/conecta2/modelo/admin/Admin.java
  4. +31
    -0
      src/main/java/es/fp/edu/conecta2/modelo/user/User.java
  5. +8
    -0
      src/main/java/es/fp/edu/conecta2/repo/admin/IAdminRepo.java
  6. +7
    -0
      src/main/java/es/fp/edu/conecta2/repo/user/IUserRepo.java
  7. +2
    -2
      src/main/resources/application.properties

+ 41
- 0
src/main/java/es/fp/edu/conecta2/BDConfig.java View File

@ -0,0 +1,41 @@
package es.fp.edu.conecta2;
import org.springframework.core.env.Environment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories (
entityManagerFactoryRef = "userEntityManagerFactory",
transactionManagerRef = "userTransactionManger",
basePackages = {"es.fp.edu.conecta2.repo.user"})
public class BDConfig {
@Autowired
private Environment env;
@Bean(name="userDataSource")
public DataSource userDatasource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl(env.getProperty("persistente.datasource.url"));
dataSource.setUsername(env.getProperty("persistente.datasource.username"));
dataSource.setPassword(env.getProperty("persistente.datasource.password"));
dataSource.setDriverClassName(env.getProperty("persistente.datasource.driver-class-name"));
return dataSource;
}
@Bean(name="userEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(){
// TODO: 27/01/2023
}
}

+ 12
- 0
src/main/java/es/fp/edu/conecta2/controladores/Controlador01.java View File

@ -0,0 +1,12 @@
package es.fp.edu.conecta2.controladores;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Controlador01 {
@GetMapping ("/")
public String prueba() {
return "Esto es una prueba";
}
}

+ 33
- 0
src/main/java/es/fp/edu/conecta2/modelo/admin/Admin.java View File

@ -0,0 +1,33 @@
package es.fp.edu.conecta2.modelo.admin;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name ="tbl_admin")
public class Admin {
public Integer getIdAdmin() {
return idAdmin;
}
public void setIdAdmin(Integer idAdmin) {
this.idAdmin = idAdmin;
}
public String getNombres() {
return nombres;
}
public void setNombres(String nombres) {
this.nombres = nombres;
}
@Id
private Integer idAdmin;
@Column(name="nombres")
private String nombres;
}

+ 31
- 0
src/main/java/es/fp/edu/conecta2/modelo/user/User.java View File

@ -0,0 +1,31 @@
package es.fp.edu.conecta2.modelo.user;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name="tbl_user")
public class User {
public Integer getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(Integer idUsuario) {
this.idUsuario = idUsuario;
}
public String getNombres() {
return nombres;
}
public void setNombres(String nombres) {
this.nombres = nombres;
}
@Id
private Integer idUsuario;
@Column(name="nombres")
private String nombres;
}

+ 8
- 0
src/main/java/es/fp/edu/conecta2/repo/admin/IAdminRepo.java View File

@ -0,0 +1,8 @@
package es.fp.edu.conecta2.repo.admin;
import es.fp.edu.conecta2.modelo.admin.Admin;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IAdminRepo extends JpaRepository <Admin, Integer> {
}

+ 7
- 0
src/main/java/es/fp/edu/conecta2/repo/user/IUserRepo.java View File

@ -0,0 +1,7 @@
package es.fp.edu.conecta2.repo.user;
import es.fp.edu.conecta2.modelo.user.User;
import org.springframework.data.jpa.repository.JpaRepository;
public interface IUserRepo extends JpaRepository<User,Integer> {
}

+ 2
- 2
src/main/resources/application.properties View File

@ -18,8 +18,8 @@ persistente.datasource.validationQuery=SELECT 1
persistente.jpa.hibernate.ddl-auto=validate
persistente.jpa.show-sql=true
persistente.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect
persistente.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
persistente.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
#persistente.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl
#persistente.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
temporal.datasource.url=jdbc:h2:file:/home/public/h2
temporal.datasource.username=sa


Loading…
Cancel
Save