Revize abaa5f46
Přidáno uživatelem Jakub Šmíd před asi 2 roky(ů)
- ID abaa5f461242c640ae1e7daaddb6bfc1b1419db9
- Rodič c1df89f5
backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeName.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.backendapi.alternativename; |
2 | 2 |
|
3 | 3 |
import cz.zcu.kiv.backendapi.catalog.CatalogItem; |
4 |
import lombok.*; |
|
4 |
import lombok.Getter; |
|
5 |
import lombok.NoArgsConstructor; |
|
6 |
import lombok.Setter; |
|
5 | 7 |
|
6 | 8 |
import javax.persistence.*; |
7 |
import java.io.Serializable;
|
|
9 |
import java.util.UUID;
|
|
8 | 10 |
|
9 | 11 |
/** |
10 | 12 |
* Alternative name entity representing alternative name of catalog item |
11 | 13 |
*/ |
12 |
@Data |
|
13 |
@EqualsAndHashCode(exclude = "catalogItem") |
|
14 |
@ToString(exclude = "catalogItem") |
|
14 |
@Getter |
|
15 |
@Setter |
|
15 | 16 |
@NoArgsConstructor |
16 |
@AllArgsConstructor |
|
17 | 17 |
@Entity |
18 | 18 |
@Table(name = "alternative_names") |
19 |
@IdClass(AlternativeName.class) |
|
20 |
public class AlternativeName implements Serializable { |
|
19 |
public class AlternativeName { |
|
21 | 20 |
/** |
22 |
* Name, serves as ID
|
|
21 |
* Id
|
|
23 | 22 |
*/ |
24 | 23 |
@Id |
24 |
@GeneratedValue |
|
25 |
private UUID id; |
|
26 |
|
|
27 |
/** |
|
28 |
* Name |
|
29 |
*/ |
|
25 | 30 |
private String name; |
26 | 31 |
|
27 | 32 |
/** |
28 | 33 |
* Catalog entity |
29 | 34 |
*/ |
30 |
@ManyToOne |
|
35 |
@ManyToOne(fetch = FetchType.LAZY)
|
|
31 | 36 |
@JoinColumn(name = "catalog_item_id") |
32 |
@Id |
|
33 | 37 |
private CatalogItem catalogItem; |
38 |
|
|
39 |
/** |
|
40 |
* Creates new alternative name with name and catalog item |
|
41 |
* |
|
42 |
* @param name name |
|
43 |
* @param catalogItem catalog item |
|
44 |
*/ |
|
45 |
public AlternativeName(String name, CatalogItem catalogItem) { |
|
46 |
this.name = name; |
|
47 |
this.catalogItem = catalogItem; |
|
48 |
} |
|
34 | 49 |
} |
Také k dispozici: Unified diff
Experiment with database