BrightSide Workbench Full Report + Source Code
TalentCategory.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2023 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.students.entities;
20 
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import org.turro.elephant.db.IdUtils;
27 import org.turro.jpa.entity.IDaoEntity;
28 import org.turro.string.Strings;
29 import org.turro.students.db.StudentsPU;
30 
35 @Entity
36 public class TalentCategory implements java.io.Serializable, IDaoEntity {
37 
38  @Id
39  @GeneratedValue(strategy=GenerationType.IDENTITY)
40  @Column(name="IDENTIFIER")
41  private Long id;
42 
43  private String name;
44 
45  public Long getId() {
46  return id;
47  }
48 
49  public void setId(Long id) {
50  this.id = id;
51  }
52 
53  public String getName() {
54  return name;
55  }
56 
57  public void setName(String name) {
58  this.name = name;
59  }
60 
61  /* IDaoEntity */
62 
63  @Override
64  public Object entityId() {
65  return id;
66  }
67 
68  @Override
69  public boolean isEmpty() {
70  return Strings.isBlank(name);
71  }
72 
73  @Override
74  public void prepareSave() {
75  IDaoEntity.super.prepareSave();
76  if(id == null || id == 0) {
77  id = IdUtils.getNewLongIdFromLong(new StudentsPU(), "TalentCategory", "id");
78  }
79  }
80 
81 }
static long getNewLongIdFromLong(Dao dao, String table, String field)
Definition: IdUtils.java:33