/** * Copyright 2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.bricket.plugin.gallery.domain; import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import org.bricket.plugin.genericdomain.domain.DomainObject; import org.bricket.plugin.picture.domain.Picture; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * @author Ingo Renner * @author Henning Teek */ @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @Entity public class Gallery extends DomainObject { @Column(nullable = false, length = 100) private String title; @Column(length = 4096) private String description; @ManyToMany @JoinTable(name = "Gallery_SubGallery", joinColumns = @JoinColumn(name = "Gallery_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "SubGallery_id", referencedColumnName = "id")) private List<Gallery> subGalleries; @ManyToMany @JoinTable(name = "Gallery_Picture", joinColumns = @JoinColumn(name = "Gallery_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "Picture_id", referencedColumnName = "id")) private List<Picture> pictures; public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public List<Gallery> getSubGalleries() { return subGalleries; } public void setSubGalleries(List<Gallery> subGalleries) { this.subGalleries = subGalleries; } public void setPictures(List<Picture> pictures) { this.pictures = pictures; } public List<Picture> getPictures() { return pictures; } @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Gallery [title=").append(title).append(", description=").append(description) .append(", subGalleries=").append(subGalleries).append(", pictures=").append(pictures).append("]"); return builder.toString(); } }