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
@Repository | |
public interface ClienteRepository extends JpaRepository<Cliente, Long> { | |
public Cliente findByRg(String pRg); | |
public Cliente findByRgAndNome (String pRg, String pNome); | |
/** | |
* Usando JPql | |
* @param pPrimeiroNome |
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
@Repository | |
public interface ClienteRepository extends JpaRepository<Cliente, Long> { | |
public Cliente findByRg(String pRg); | |
public Cliente findByRgAndNome (String pRg, String pNome); | |
} |
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
@Repository | |
public interface ClienteRepository extends JpaRepository<Cliente, Long> { | |
public Cliente findByRg(String pRg); | |
} |
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
@Repository | |
public interface ClienteRepository extends JpaRepository<Cliente, Long> { | |
// não preciso definir nenhum método ainda! | |
} |
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
@Entity | |
@Table(name = "CLIENTE") | |
public class Cliente { | |
@Id | |
@GeneratedValue(strategy = GenerationType.AUTO) | |
private Long id; | |
@Column | |
private String nome; |
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: | |
jpa: | |
hibernate: | |
ddl-auto: create-drop | |
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy | |
database-platform: org.hibernate.dialect.H2Dialect | |
show-sql: true | |
datasource: | |
url: jdbc:h2:mem:exemploparte2;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE | |
username: sa |
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
// ... | |
compile('org.springframework.boot:spring-boot-starter-data-jpa') | |
runtime('com.h2database:h2') | |
// ... |
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
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-data-jpa</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>com.h2database</groupId> | |
<artifactId>h2</artifactId> | |
</dependency> |
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
environments { | |
tenancies { | |
mainTenant { | |
database { | |
username = 'MAIN' | |
password = 'MAIN' | |
url = 'jdbc:oracle:thin:@localhost:1521:xe' | |
tablespace = 'TBS_DADOS' | |
indexspace = 'TBS_INDICES' | |
lobspace = 'TBS_LOBS' |
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 DatasourceIdResolverImpl implements DatasourceIdResolver { | |
public String getCurrentDatasourceId() { | |
return TenantContext.getCurrentTenant().getTenantId(); | |
} | |
} |