EJB3 Annotation Sample
源代码在线查看: content.java.svn-base
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.s7turn.content.entities; import com.s7turn.sdk.content.ContentInfo; import com.s7turn.sdk.content.DirectoryInfo; import java.io.Serializable; import java.sql.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; /** * * @author Long */ @Entity @Table( name = "contents" ) @NamedQueries( { @NamedQuery( name= "Content.findContentsByResourceId", query = "SELECT ic FROM Content ic WHERE ic.resourceId = :resourceId"), @NamedQuery( name= "Content.findContentById", query = "SELECT ic FROM Content ic WHERE ic.id = :id"), @NamedQuery( name= "Content.findAllContent", query = "SELECT ic FROM Content ic "), @NamedQuery( name= "Content.findContentsInDirectory", query = "SELECT ic FROM Content ic WHERE ic.parent = :directory"), @NamedQuery( name= "Content.findContentByChannel", query = "SELECT ic FROM Content ic WHERE ic.channel=:channel"), @NamedQuery( name= "Content.findContentByCategory", query = "SELECT ic FROM Content ic WHERE ic.channel=:channel AND ic.category=:category"), @NamedQuery( name= "Content.findContentBySubCategory", query = "SELECT ic FROM Content ic WHERE ic.channel=:channel AND ic.category=:category AND ic.subCategory=:subCategory") }) public class Content implements ContentInfo, Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue( strategy = GenerationType.SEQUENCE ) @Column( name = "content_id") private Long id; @Column( name = "content_key") private String contentKey; @Column( name = "resource_id") private String resourceId; @Column( name = "body") private String body; @Column( name = "author") private String author; @Column( name = "last_update") private Date lastUpdate; @Column( name = "create_date") private Date createDate; @Column( name = "content_tags") private String tags; @JoinColumn( name = "template") private Template template; @JoinColumn( name = "channel_id") private Channel channel; @JoinColumn( name = "category_id") private Category category; @JoinColumn( name = "subcategory_id") private SubCategory subCategory; @JoinColumn( name = "directory_id") private Directory parent; @Column( name = "content_name" ) private String name; @Column( name = "subject") private String subject; @Column( name = "file_type") private String fileType; @Column( name = "keywords") private String keywords; public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; } public Channel getChannel() { return channel; } public void setChannel(Channel channel) { this.channel = channel; } public String getFileType() { return fileType; } public void setFileType(String fileType) { this.fileType = fileType; } public String getKeywords() { return keywords; } public void setKeywords(String keywords) { this.keywords = keywords; } public SubCategory getSubCategory() { return subCategory; } public void setSubCategory(SubCategory subCategory) { this.subCategory = subCategory; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public Template getTemplate() { return template; } public void setTemplate(Template template) { this.template = template; } /* @OneToMany( targetEntity = ContentProperty.class, mappedBy = "content" ) private List properties; public List getProperties() { return properties; } public void setProperties(List properties) { this.properties = properties; } */ public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getTags() { return tags; } public void setTags(String t) { this.tags = t; } public Date getCreateDate() { return createDate; } public void setCreateDate(Date createDate) { this.createDate = createDate; } public Date getLastUpdate() { return lastUpdate; } public void setLastUpdate(Date lastUpdate) { this.lastUpdate = lastUpdate; } public void setId(Long id) { this.id = id; } public Long getId() { return id; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Content)) { return false; } Content other = (Content) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "com.s7turn.filesharing.entities.Content[id=" + id + "]"; } public void setContentKey(String vid) { contentKey = vid; } public String getContentKey() { return contentKey; } public String getResourceId() { return resourceId; } public void setResourceId(String rid) { resourceId = rid; } public String getBody() { return body; } public void setBody(String bd) { body = bd; } public DirectoryInfo getParent() { return parent; } public void setParent(DirectoryInfo ci) { parent = (Directory) ci; } public String getName() { return name; } public void setName(String name) { this.name = name; } public boolean isDirectory() { return false; } }