Project

General

Profile

« Previous | Next » 

Revision 37126

resource properties management

View differences:

HibDnetResourceProperty.java
2 2

  
3 3
import java.io.Serializable;
4 4

  
5
import javax.persistence.Column;
5
import javax.persistence.EmbeddedId;
6 6
import javax.persistence.Entity;
7
import javax.persistence.Id;
8
import javax.persistence.JoinColumn;
9
import javax.persistence.ManyToOne;
10 7
import javax.persistence.Table;
11 8
import javax.persistence.Transient;
12 9

  
......
15 12
public class HibDnetResourceProperty extends HibDnetObject implements Serializable {
16 13

  
17 14
	@Transient
18
	private static final long serialVersionUID = 612491084747663805L;
15
	private static final long serialVersionUID = -2095052466902711468L;
19 16

  
20
	@Id
21
	@Column(name = "id", insertable = false)
22
	private int id;
17
	@EmbeddedId
18
	private HibDnetResourcePropertyId id;
23 19

  
24
	@ManyToOne
25
	@JoinColumn(name = "resource", nullable = false)
26
	private HibDnetResource resource;
27

  
28
	@Column(name = "name", nullable = false)
29
	private String name;
30

  
31
	@Column(name = "value")
32
	private String value;
33

  
34 20
	public HibDnetResourceProperty() {}
35 21

  
36
	public HibDnetResourceProperty(final int id, final HibDnetResource resource, final String name, final String value) {
22
	public HibDnetResourceProperty(final HibDnetResourcePropertyId id) {
37 23
		this.id = id;
38
		this.resource = resource;
39
		this.name = name;
40
		this.value = value;
41 24
	}
42 25

  
43 26
	public HibDnetResourceProperty(final HibDnetResource resource, final String name, final String value) {
44
		this(-1, resource, name, value);
27
		this.id = new HibDnetResourcePropertyId(resource, name, value);
45 28
	}
46 29

  
47
	public int getId() {
30
	public final HibDnetResourcePropertyId getId() {
48 31
		return id;
49 32
	}
50 33

  
51
	public void setId(final int id) {
34
	public final void setId(final HibDnetResourcePropertyId id) {
52 35
		this.id = id;
53 36
	}
54 37

  
55
	public HibDnetResource getResource() {
56
		return resource;
57
	}
58

  
59
	public void setResource(final HibDnetResource resource) {
60
		this.resource = resource;
61
	}
62

  
63 38
	public String getName() {
64
		return name;
39
		return id.getName();
65 40
	}
66 41

  
67
	public void setName(final String name) {
68
		this.name = name;
69
	}
70

  
71 42
	public String getValue() {
72
		return value;
43
		return id.getValue();
73 44
	}
74 45

  
75
	public void setValue(final String value) {
76
		this.value = value;
77
	}
78

  
79 46
	@Override
80 47
	public int hashCode() {
81
		return id;
48
		return id.hashCode();
82 49
	}
83 50
}

Also available in: Unified diff