-
-
Save fabriciofx/10001880 to your computer and use it in GitHub Desktop.
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 | |
public class Bem implements Serializable { | |
private static final long serialVersionUID = 1L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
private Long id; | |
@ManyToOne | |
@JoinColumn(nullable = false) | |
private Lotacao lotacao; | |
@Transient | |
private boolean estaAtreladoAMovimentacao; | |
/** | |
* Default constructor | |
* / | |
public Bem() {} | |
public Bem(Bem bem, boolean estaAtreladoAMovimentacao) { | |
this.id = bem.id; | |
this.lotacao = bem.lotacao; | |
this.estaAtreladoAMovimentacao = estaAtreladoAMovimentacao; | |
} | |
public Bem(Bem bem, Long movId) { | |
this.id = bem.id; | |
this.lotacao = bem.lotacao; | |
this.estaAtreladoAMovimentacao = movId != null; | |
} | |
} |
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
select new Bem(bem, case when mov.id is not null then true else false end) | |
from Movimentacao mov | |
left join mov.bem as bem | |
with bem.lotacao = :lotacao | |
where mov.id = 69 |
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
select new Bem(bem, mov.id) | |
from Movimentacao mov | |
left join mov.bem as bem | |
with bem.lotacao = :lotacao | |
where mov.id = 69 |
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 | |
public class Movimentacao implements Serializable { | |
private static final long serialVersionUID = 1L; | |
@Id | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | |
private Long id; | |
@ManyToOne | |
@JoinColumn(nullable = false) | |
private Bem bem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment