- •Отчет по лабораторной работе «Система учета прохода в здание»
- •Инструкция для администратора:
- •Запуск административной web-консоли GlassFish
- •Регистрация источника данных в jndi
- •Books.Java
- •LibrarySession.Java
- •Add_authors.Jsp
- •Add_books.Jsp
- •All_books.Jsp
- •Index.Jsp
- •Return_b.Jsp
- •Return_book.Jsp
- •Search_b.Jsp
- •Search_books.Jsp
- •Take_b.Jsp
- •Take_book.Jsp
- •Тестирование
- •Выводы:
Books.Java
package library;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Table(name = "BOOKS")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Books.findAll", query = "SELECT b FROM Books b"),
@NamedQuery(name = "Books.findById", query = "SELECT b FROM Books b WHERE b.id = :id"),
@NamedQuery(name = "Books.findByName", query = "SELECT b FROM Books b WHERE b.name = :name"),
@NamedQuery(name = "Books.findByLocation", query = "SELECT b FROM Books b WHERE b.location = :location"),
@NamedQuery(name = "Books.findByCnt", query = "SELECT b FROM Books b WHERE b.cnt = :cnt"),
@NamedQuery(name = "Books.findByNameOrAuthor",
query = "SELECT b FROM Books b JOIN b.assignedAuthor a WHERE"
+ " (b.name LIKE :name AND a.name LIKE :author AND :name != '' AND :author != '' )"
+ " OR (b.name LIKE :name AND :name != '' AND :author = '' )"
+ " OR (a.name LIKE :author AND :name = '' AND :author != '' )"
),
@NamedQuery(name = "Books.findByTohand", query = "SELECT b FROM Books b WHERE b.tohand = :tohand")})
public class Books implements Serializable {
private static final long serialVersionUID = 1L;
@ManyToOne
@NotNull
private Author assignedAuthor;
public Author getAssignedAuthor() {
return assignedAuthor;
}
public void setAssignedAuthor(Author author) {
this.assignedAuthor = author;
}
@Id
@Basic(optional = false)
@NotNull
@GeneratedValue
@Column(name = "ID")
private Integer id;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 120)
@Column(name = "NAME")
private String name;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 100)
@Column(name = "LOCATION")
private String location;
@Basic(optional = false)
@NotNull
@Column(name = "CNT")
private int cnt;
@Basic(optional = false)
@NotNull
@Column(name = "TOHAND")
private int tohand;
public Books() {
}
public Books(Integer id) {
this.id = id;
}
public Books(Integer id, String name, String location, int cnt, int tohand) {
this.id = id;
this.name = name;
this.location = location;
this.cnt = cnt;
this.tohand = tohand;
}
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;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public int getCnt() {
return cnt;
}
public void setCnt(int cnt) {
this.cnt = cnt;
}
public int getTohand() {
return tohand;
}
public void setTohand(int tohand) {
this.tohand = tohand;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof Books)) {
return false;
}
Books other = (Books) 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 "library.Books[ id=" + id + " ]";
}
}
