0
I have the inheritance to do below and would like to know how it would look on main. Someone here could help?
Could you tell me if you have any problems with the mapping I did and how mainTeste would look? I cannot define the value of the Lancamentodesparcelado class...
I use:
1º the Eclipse;
2nd Oracle database and to view the database tables use oracle SQL Developer;
3º And in the project we will use the strategy of multiple tables with use of Join;
I’ll put the beginning of the classes:
RELEASE
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(NAME="TIPO", discriminatorType=DiscriminatorType.CHAR)
@Table(name="LANCAMENTO")
public class Lancamento extends GenericModel{ ... }
LANCAMENTO_DESPESA
@Entity
public class LancamentoDespesa extends Lancamento{ ... }
LANCAMENTO_RECEITA
@Entity
public class LancamentoReceita extends Lancamento{ ... }
LANCAMENTO_DESPESA_PARCELADA
@Entity
public class LancamentoDespesa extends LancamentoDespesa{
@Column(name = "PARCELA", nullable = true)
private int numParcela;
GET/SET...
}
Final remarks: In SQL Developer creates inheritance tables, but also creates 4 other tables with names:
HT_LANCAMENTO
HT_LANCAMENTODESPESA
HT_LANCAMENTORECEITA
HT_LANCAMENTODESPESAPARCELADA
And all have in the drawing of the table a little box with x.
I can’t get another picture in here if I wouldn’t.
And what would be the main part of the unitary test to launch LANCAMENTO? How do I launch the plots of the LANCAMENTODESPARCELADA class?
– Rafael Blum
Lancamento lancamento = new Lancamentodespesaparcelada(); service.save(lancamento);
– Roque Santos
Yes. I did it, okay, but at what point do I define the plots? intende... ai que ficou perdido. This system is for financial launches of REVENUE or EXPENSE, and correct me if I’m wrong... I WON’T instantiate LANCAMENTO, I always have to instantiate and choose LANCAMENTO_DESPESA or LANCAMENTO_RECEITA or if it is installments LANCAMENTO_DESPESA_PARCELADA, this PQ I will have everything LANCAMENTO and in case if installments, I have INSTALLMENT... this is the reasoning... sorry if I’m wrong.
– Rafael Blum
Try it now, and that’s it, Roque. In SQL Developer in the LANCAMENTO table I have all data and in the TYPE column I have 3 (from the LANCAMENTODESPARCELADA table). And in the table LANCAMENTODESPESAPARCELADA I have the id of the LANCAMENTO and the value of plots of the column PARCELA = 10.
– Rafael Blum
Cool. If I helped you, please mark the answer as correct :)
– Roque Santos
I forgot that for example when we have PERSON and we have TRAINEE and EMPLOYEE who inherit from PERSON, we never INSTANCE PERSON and yes INTERN or EMPLOYEE. Helped yes!
– Rafael Blum