@Immutable public static class ImmutableState { private final String state; public ImmutableState(String state) { this.state = state; } public String getState() { return state; } @Override public boolean equals(Object o) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } ImmutableState that = (ImmutableState) o; return getState().equals( that.getState() ); } @Override public int hashCode() { return getState().hashCode(); } }
@OneToMany @JoinColumn( name = "BUILDING_OWNER_ID" ) @Immutable public Set<Rating> getRatingsFromCombined() { return ratingsFromCombined; } public void setRatingsFromCombined(Set<Rating> ratingsFromCombined) {
@OneToMany @JoinColumn( name = "BUILDING_OWNER_ID" ) @Immutable public Set<Size> getSizesFromCombined() { return sizesFromCombined; } public void setSizesFromCombined(Set<Size> sizesFromCombined) {
@Immutable public class Caption {
@Immutable @SuppressWarnings("serial") public class Exif implements Serializable {
@OneToMany @JoinColumn( name = "MATERIAL_OWNER_ID" ) @Immutable public Set<Size> getSizesFromCombined() { return sizesFromCombined; } public void setSizesFromCombined(Set<Size> sizesFromCombined) {
/** * @author Hardy Ferentschik */ @Entity @Immutable @Table(name = "ENTITY") public class TestEntity implements Serializable { @EmbeddedId private Ref ref; @Column(name = "NAME", insertable = false, updatable = false, unique = true) private String name; }
@OneToMany @JoinColumn( name = "MATERIAL_OWNER_ID") @Where( clause = "name = 'high' or name = 'medium'" ) @Immutable public List<Rating> getMediumOrHighRatingsFromCombined() { return mediumOrHighRatingsFromCombined; } public void setMediumOrHighRatingsFromCombined(List<Rating> mediumOrHighRatingsFromCombined) {
@Entity(name = "TheEntity") @Table(name = "THE_ENTITY") @Cacheable @Immutable public static class TheEntity { @Id public Long id; } }
@ElementCollection @CollectionTable( name = "MATERIAL_RATINGS", joinColumns = { @JoinColumn( name = "MATERIAL_ID" ) } ) @Column( name="RATING") @Immutable public Set<String> getRatings() { return ratings; } public void setRatings(Set<String> ratings) {
/** * @author Hardy Ferentschik */ @Entity public class Foobar { @Id @GeneratedValue private Integer id; @Immutable private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } }
@Entity(name = "Event") @Immutable public static class Event { @Id private Long id; private Date createdOn; private String message; //Getters and setters are omitted for brevity //end::entity-immutability-example[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Date getCreatedOn() { return createdOn; } public void setCreatedOn(Date createdOn) { this.createdOn = createdOn; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } //tag::entity-immutability-example[] } //end::entity-immutability-example[]
@Entity(name = "Event") @Immutable public static class Event { @Id private Long id; private Date createdOn; private String message; //Getters and setters are omitted for brevity //end::collection-immutability-example[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Date getCreatedOn() { return createdOn; } public void setCreatedOn(Date createdOn) { this.createdOn = createdOn; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } //tag::collection-immutability-example[] } //end::collection-immutability-example[]
@Entity(name = "Batch") public static class Batch { @Id private Long id; private String name; @OneToMany(cascade = CascadeType.ALL) @Immutable private List<Event> events = new ArrayList<>( ); //Getters and setters are omitted for brevity //end::collection-immutability-example[] public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public List<Event> getEvents() { return events; } //tag::collection-immutability-example[] }
@ElementCollection @CollectionTable( name = "COLLECTION_TABLE", joinColumns = { @JoinColumn( name = "MAIN_ID" ) } ) @Column( name="VALUE") @Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='SIZE'") @Immutable public Set<String> getSizesFromCombined() { return sizesFromCombined; } public void setSizesFromCombined(Set<String> sizesFromCombined) {
@ElementCollection @CollectionTable( name = "COLLECTION_TABLE", joinColumns = { @JoinColumn( name = "MAIN_ID" ) } ) @Column( name="VALUE") @Where( clause = "MAIN_CODE='MATERIAL' AND VALUE_CODE='SIZE'") @Immutable public Set<String> getSizesFromCombined() { return sizesFromCombined; } public void setSizesFromCombined(Set<String> sizesFromCombined) {
@ElementCollection @CollectionTable( name = "COLLECTION_TABLE", joinColumns = { @JoinColumn( name = "MAIN_ID" ) } ) @Column( name="VALUE") @Where( clause = "MAIN_CODE='BUILDING' AND VALUE_CODE='RATING'" ) @Immutable public Set<String> getRatingsFromCombined() { return ratingsFromCombined; } public void setRatingsFromCombined(Set<String> ratingsFromCombined) {
@ElementCollection @CollectionTable( name = "COLLECTION_TABLE", joinColumns = { @JoinColumn( name = "MAIN_ID" ) } ) @Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='SIZE'") @Immutable public Set<ContainedSize> getContainedSizesFromCombined() { return containedSizesFromCombined; } public void setContainedSizesFromCombined(Set<ContainedSize> containedSizesFromCombined) {
@ElementCollection @CollectionTable( name = "COLLECTION_TABLE", joinColumns = { @JoinColumn( name = "MAIN_ID" ) } ) @Where( clause = "MAIN_CODE='BUILDING' AND ASSOCIATION_CODE='RATING'" ) @Immutable public Set<ContainedRating> getContainedRatingsFromCombined() { return containedRatingsFromCombined; } public void setContainedRatingsFromCombined(Set<ContainedRating> containedRatingsFromCombined) {
@OneToMany @JoinColumn(name = "mainstreetcity_id") @ForeignKey(name = "CITYSTR_FK") @OrderBy @Immutable public List<Street> getMainStreets() { return mainStreets; }