Created
November 22, 2016 17:33
-
-
Save thjanssen/66ecc4094ed65bf464724e0103cf173c 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
| @Entity | |
| @NamedQuery(name = “Account.FindByName”, query = “SELECT a FROM Account a WHERE name like :name”) | |
| public class Account { | |
| @Id | |
| @GeneratedValue(strategy = GenerationType.AUTO) | |
| @Column(name = “id”, updatable = false, nullable = false) | |
| private Long id; | |
| @Column | |
| private String name; | |
| @Column | |
| @Enumerated(EnumType.STRING) | |
| private AccountState state; | |
| … | |
| } |
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
| Account a = em.find(Account.class, a.getId()); | |
| em.remove(a); |
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
| 16:07:59,511 DEBUG SQL:92 – select account0_.id as id1_0_0_, account0_.name as name2_0_0_, account0_.state as state3_0_0_ from Account account0_ where account0_.id=? and ( account0_.state <> ‘DELETED’) | |
| 16:07:59,534 DEBUG SQL:92 – UPDATE account SET state = ‘DELETED’ WHERE id = ? |
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
| Account a = em.find(Account.class, a.getId()); |
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
| 16:07:59,540 DEBUG SQL:92 – select account0_.id as id1_0_0_, account0_.name as name2_0_0_, account0_.state as state3_0_0_ from Account account0_ where account0_.id=? and ( account0_.state <> ‘DELETED’) |
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
| TypedQuery<Account> q = em.createNamedQuery(“Account.FindByName”, Account.class); | |
| q.setParameter(“name”, “%ans%”); | |
| Account a = q.getSingleResult(); |
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
| 16:07:59,511 DEBUG SQL:92 – select account0_.id as id1_0_, account0_.name as name2_0_, account0_.state as state3_0_ from Account account0_ where ( account0_.state <> ‘DELETED’) and (account0_.name like ?) |
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
| @Entity | |
| @SQLDelete(sql = “UPDATE account SET state = ‘DELETED’ WHERE id = ?”, check = ResultCheckStyle.COUNT) | |
| public class Account { | |
| … | |
| @PreRemove | |
| public void deleteUser() { | |
| this.state = AccountState.DELETED; | |
| } | |
| } |
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
| @Entity | |
| @SQLDelete(sql = “UPDATE account SET state = ‘DELETED’ WHERE id = ?”, check = ResultCheckStyle.COUNT) | |
| public class Account { … } |
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
| @Entity | |
| @SQLDelete(sql = “UPDATE account SET state = ‘DELETED’ WHERE id = ?”, check = ResultCheckStyle.COUNT) | |
| @Where(clause = “state <> ‘DELETED'”) | |
| @NamedQuery(name = “Account.FindByName”, query = “SELECT a FROM Account a WHERE name like :name”) | |
| public class Account { … } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment