1 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 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 id; 42 private String name; 43 private long length; 44 private String longDescription; 45 private String smallText; 46 private String bigText; 47 private Country country; 48 49 @Type(type="text") 50 public String getLongDescription() { 51 return longDescription; 52 } 53 54 public void setLongDescription(String 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 getId() { 68 return id; 69 } 70 71 public void setId(Integer id) { 72 this.id = id; 73 } 74 75 public String getName() { 76 return name; 77 } 78 79 public void setName(String name) { 80 this.name = name; 81 } 82 83 @Type(type="caster") 84 public String getSmallText() { 85 return smallText; 86 } 87 88 @Type(type="caster", parameters = { @Parameter( name="cast", value = "upper" ) } ) 89 public String getBigText() { 90 return bigText; 91 } 92 93 public void setSmallText(String smallText) { 94 this.smallText = smallText; 95 } 96 97 public void setBigText(String 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 |