KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > test > annotations > entity > Forest


1 //$Id: Forest.java,v 1.3 2005/07/26 04:57:09 epbernard Exp $
2
package org.hibernate.test.annotations.entity;
3
4 import javax.persistence.Entity;
5 import javax.persistence.GeneratorType;
6 import javax.persistence.Id;
7 import javax.persistence.Lob;
8 import javax.persistence.LobType;
9
10 import org.hibernate.annotations.BatchSize;
11 import org.hibernate.annotations.Filter;
12 import org.hibernate.annotations.FilterDef;
13 import org.hibernate.annotations.Filters;
14 import org.hibernate.annotations.OptimisticLockType;
15 import org.hibernate.annotations.ParamDef;
16 import org.hibernate.annotations.Parameter;
17 import org.hibernate.annotations.PolymorphismType;
18 import org.hibernate.annotations.Type;
19 import org.hibernate.annotations.Where;
20 import org.hibernate.annotations.Index;
21
22 /**
23  * Use hibernate specific annotations
24  * @author Emmanuel Bernard
25  */

26 @Entity
27 @BatchSize(size=5)
28 @org.hibernate.annotations.Entity(
29         selectBeforeUpdate = true,
30         dynamicInsert = true, dynamicUpdate = true,
31         optimisticLock = OptimisticLockType.ALL,
32         polymorphism = PolymorphismType.EXPLICIT)
33 @Where(clause="1=1")
34 @FilterDef(name="minLength", parameters={ @ParamDef( name="minLength", type="integer" ) } )
35 @Filters( {
36     @Filter(name="betweenLength", condition=":minLength <= length and :maxLength >= length"),
37     @Filter(name="minLength", condition=":minLength <= length")
38 } )
39 @org.hibernate.annotations.Table(name="Forest", indexes = { @Index(name="idx", columnNames = { "name", "length" } ) } )
40 public class Forest {
41     private Integer JavaDoc id;
42     private String JavaDoc name;
43     private long length;
44     private String JavaDoc longDescription;
45     private String JavaDoc smallText;
46     private String JavaDoc bigText;
47     private Country country;
48
49     @Type(type="text")
50     public String JavaDoc getLongDescription() {
51         return longDescription;
52     }
53
54     public void setLongDescription(String JavaDoc longDescription) {
55         this.longDescription = longDescription;
56     }
57
58     public long getLength() {
59         return length;
60     }
61
62     public void setLength(long length) {
63         this.length = length;
64     }
65
66     @Id(generate = GeneratorType.AUTO)
67     public Integer JavaDoc getId() {
68         return id;
69     }
70
71     public void setId(Integer JavaDoc id) {
72         this.id = id;
73     }
74
75     public String JavaDoc getName() {
76         return name;
77     }
78
79     public void setName(String JavaDoc name) {
80         this.name = name;
81     }
82
83     @Type(type="caster")
84     public String JavaDoc getSmallText() {
85         return smallText;
86     }
87
88     @Type(type="caster", parameters = { @Parameter( name="cast", value = "upper" ) } )
89     public String JavaDoc getBigText() {
90         return bigText;
91     }
92
93     public void setSmallText(String JavaDoc smallText) {
94         this.smallText = smallText;
95     }
96
97     public void setBigText(String JavaDoc bigText) {
98         this.bigText = bigText;
99     }
100
101     @Lob(type=LobType.BLOB)
102     public Country getCountry() {
103         return country;
104     }
105
106     public void setCountry(Country country) {
107         this.country = country;
108     }
109 }
110
Popular Tags