/* * DbItem.java * * Created on June 13, 2007, 9:21 PM * * */ package org.webonweb.runtime.impl.repository.db.jpa; import java.io.Serializable; import java.math.BigInteger; import java.util.Collection; import java.util.Date; import javax.persistence.CascadeType; 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.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * Entity class DbItem * * @author girix */ @Entity @Table(name = "ITEM") @NamedQueries( { @NamedQuery(name = "DbItem.findById", query = "SELECT d FROM DbItem d WHERE d.id = :id"), @NamedQuery(name = "DbItem.findByUri", query = "SELECT d FROM DbItem d WHERE d.uri = :uri"), @NamedQuery(name = "DbItem.findByCreatedTimestamp", query = "SELECT d FROM DbItem d WHERE d.createdTimestamp = :createdTimestamp"), @NamedQuery(name = "DbItem.findByItemType", query = "SELECT d FROM DbItem d WHERE d.itemType = :itemType") }) public class DbItem implements Serializable { @Id @Column(name = "ID", nullable = false) @GeneratedValue(strategy=GenerationType.IDENTITY) private BigInteger id; @Column(name = "URI", nullable = false) private String uri; @Column(name = "CREATED_TIMESTAMP", insertable=false, updatable=false) @Temporal(TemporalType.TIMESTAMP) private Date createdTimestamp; @Column(name = "ITEM_TYPE", nullable = false) private String itemType; @OneToMany(mappedBy = "itemId") private Collection dbServiceCollection; @OneToMany(cascade={CascadeType.REMOVE,CascadeType.PERSIST}, mappedBy = "itemId") private Collection dbItemVersionCollection; @OneToMany(cascade={CascadeType.REMOVE,CascadeType.PERSIST}, mappedBy = "itemId") private Collection dbItemDraftCollection; @OneToMany(mappedBy = "activeId") private Collection dbNamespaceCollection; @JoinColumn(name = "SECURED", referencedColumnName = "ID") @ManyToOne private DbSecured secured; /** Creates a new instance of DbItem */ public DbItem() { } /** * Creates a new instance of DbItem with the specified values. * @param id the id of the DbItem */ public DbItem(BigInteger id) { this.id = id; } /** * Creates a new instance of DbItem with the specified values. * @param id the id of the DbItem * @param uri the uri of the DbItem * @param itemType the itemType of the DbItem */ public DbItem(BigInteger id, String uri, String itemType) { this.id = id; this.uri = uri; this.itemType = itemType; } /** * Gets the id of this DbItem. * @return the id */ public BigInteger getId() { return this.id; } /** * Sets the id of this DbItem to the specified value. * @param id the new id */ public void setId(BigInteger id) { this.id = id; } /** * Gets the uri of this DbItem. * @return the uri */ public String getUri() { return this.uri; } /** * Sets the uri of this DbItem to the specified value. * @param uri the new uri */ public void setUri(String uri) { this.uri = uri; } /** * Gets the createdTimestamp of this DbItem. * @return the createdTimestamp */ public Date getCreatedTimestamp() { return this.createdTimestamp; } /** * Sets the createdTimestamp of this DbItem to the specified value. * @param createdTimestamp the new createdTimestamp */ public void setCreatedTimestamp(Date createdTimestamp) { this.createdTimestamp = createdTimestamp; } /** * Gets the itemType of this DbItem. * @return the itemType */ public String getItemType() { return this.itemType; } /** * Sets the itemType of this DbItem to the specified value. * @param itemType the new itemType */ public void setItemType(String itemType) { this.itemType = itemType; } /** * Gets the dbServiceCollection of this DbItem. * @return the dbServiceCollection */ public Collection getDbServiceCollection() { return this.dbServiceCollection; } /** * Sets the dbServiceCollection of this DbItem to the specified value. * @param dbServiceCollection the new dbServiceCollection */ public void setDbServiceCollection(Collection dbServiceCollection) { this.dbServiceCollection = dbServiceCollection; } /** * Gets the dbItemVersionCollection of this DbItem. * @return the dbItemVersionCollection */ public Collection getDbItemVersionCollection() { return this.dbItemVersionCollection; } /** * Sets the dbItemVersionCollection of this DbItem to the specified value. * @param dbItemVersionCollection the new dbItemVersionCollection */ public void setDbItemVersionCollection(Collection dbItemVersionCollection) { this.dbItemVersionCollection = dbItemVersionCollection; } /** * Gets the dbItemDraftCollection of this DbItem. * @return the dbItemDraftCollection */ public Collection getDbItemDraftCollection() { return this.dbItemDraftCollection; } /** * Sets the dbItemDraftCollection of this DbItem to the specified value. * @param dbItemDraftCollection the new dbItemDraftCollection */ public void setDbItemDraftCollection(Collection dbItemDraftCollection) { this.dbItemDraftCollection = dbItemDraftCollection; } /** * Gets the dbNamespaceCollection of this DbItem. * @return the dbNamespaceCollection */ public Collection getDbNamespaceCollection() { return this.dbNamespaceCollection; } /** * Sets the dbNamespaceCollection of this DbItem to the specified value. * @param dbNamespaceCollection the new dbNamespaceCollection */ public void setDbNamespaceCollection(Collection dbNamespaceCollection) { this.dbNamespaceCollection = dbNamespaceCollection; } /** * Returns a hash code value for the object. This implementation computes * a hash code value based on the id fields in this object. * @return a hash code value for this object. */ @Override public int hashCode() { int hash = 0; hash += (this.id != null ? this.id.hashCode() : 0); return hash; } /** * Determines whether another object is equal to this DbItem. The result is * true if and only if the argument is not null and is a DbItem object that * has the same id field values as this object. * @param object the reference object with which to compare * @return true if this object is the same as the argument; * false otherwise. */ @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 DbItem)) { return false; } DbItem other = (DbItem)object; if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) return false; return true; } /** * Returns a string representation of the object. This implementation constructs * that representation based on the id fields. * @return a string representation of the object. */ @Override public String toString() { return "org.webonweb.runtime.impl.repository.db.jpa.DbItem[id=" + id + "]"; } public DbSecured getSecured() { return secured; } public void setSecured(DbSecured secured) { this.secured = secured; } }