Last active
November 9, 2019 13:38
-
-
Save augustovictor/3ceba44434d4492ffcd85b1382c00b52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@SpringBootApplication | |
class MedAvailableApplication | |
fun main(args: Array<String>) { | |
val application = runApplication<MedAvailableApplication>(*args).getBean(GuiaContabilRepository::class.java) | |
val result = application.save(ImportacaoContrato()) | |
} | |
/////////////////////////////////////////////////// | |
package com.augustovictor.medavailable | |
import javax.persistence.* | |
@Entity | |
@Table(name = "guia_contabil") | |
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | |
@DiscriminatorColumn(name = "tipo_guia") | |
abstract class GuiaContabil{ | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
val id: Long = 0 | |
} | |
@Entity | |
@DiscriminatorValue("importacao_contrato") | |
class ImportacaoContrato : GuiaContabil() | |
/////////////////////////////////////////////////// | |
package com.augustovictor.medavailable | |
import org.springframework.data.repository.Repository | |
interface GuiaContabilRepository : Repository<GuiaContabil, Long> { | |
fun save(guiaContabil: GuiaContabil): GuiaContabil | |
} | |
/////////////////////////////////////////////////// | |
// V1__.sql | |
// CREATE TABLE public.guia_contabil( | |
// id BIGSERIAL PRIMARY KEY, | |
// tipo_guia character(255) NOT NULL | |
// ); | |
/////////////////////////////////////////////////// | |
//medavailabledb=# select * from guia_contabil; | |
//id | tipo_guia | |
//----+----------------------- | |
// 1 | ImportacaoContrato | |
// | |
// 2 | ImportacaoContrato | |
// | |
// 3 | ImportacaoContrato | |
// | |
// 4 | ImportacaoContrato | |
// | |
// 5 | ImportacaoContratoAlterada | |
// | |
// 6 | importacao_contrato | |
// | |
// 7 | importacao_contrato |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment