package entity; /** * */ import java.util.Date; import java.util.HashSet; import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; /** * @author Liang ZHANG * */ @SuppressWarnings(value = "serial") @Entity @Table(name = "ISBN_BOOK") @DiscriminatorValue(value = "I") @NamedQueries(value = {@NamedQuery(name = "ISBNBook.findViaAuthor", query = "SELECT g FROM ISBNBook g WHERE g.author = :author"), @NamedQuery(name = "ISBNBook.findViaBookName", query = "SELECT g FROM ISBNBook g WHERE g.bookName = :bookname"), @NamedQuery(name = "ISBNBook.findViaCurrentLocation", query = "SELECT g FROM ISBNBook g WHERE g.currentLocation = :currentlocation"), @NamedQuery(name = "ISBNBook.findViaISBNNumber", query = "SELECT g FROM ISBNBook g WHERE g.iSBNNumber = :isbnnumber")}) public class ISBNBook extends ContentMedia { /** AK of this kind of content media. * @generated "UML to EJB (uml2.ejb.transformation)" */ @Column(name = "ISBN_NUMBER") private String iSBNNumber; /** * @return the iSBNNumber * @generated "UML to EJB (uml2.ejb.transformation)" */ public String getISBNNumber() { return iSBNNumber; } /** * @param theISBNNumber the iSBNNumber to set * @generated "UML to EJB (uml2.ejb.transformation)" */ public void setISBNNumber(String theISBNNumber) { iSBNNumber = theISBNNumber; } /** * * @generated "UML to EJB (uml2.ejb.transformation)" */ @Column(name = "BOOK_NAME") private String bookName; /** * @return the bookName * @generated "UML to EJB (uml2.ejb.transformation)" */ public String getBookName() { return bookName; } /** * @param theBookName the bookName to set * @generated "UML to EJB (uml2.ejb.transformation)" */ public void setBookName(String theBookName) { bookName = theBookName; } /** * * @generated "UML to EJB (uml2.ejb.transformation)" */ @Column(name = "AUTHOR") private String author; /** * @return the author * @generated "UML to EJB (uml2.ejb.transformation)" */ public String getAuthor() { return author; } /** * @param theAuthor the author to set * @generated "UML to EJB (uml2.ejb.transformation)" */ public void setAuthor(String theAuthor) { author = theAuthor; } /** * * @generated "UML to EJB (uml2.ejb.transformation)" */ @Column(name = "CURRENT_LOCATION") private String currentLocation; /** * @return the currentLocation * @generated "UML to EJB (uml2.ejb.transformation)" */ public String getCurrentLocation() { return currentLocation; } /** * @param theCurrentLocation the currentLocation to set * @generated "UML to EJB (uml2.ejb.transformation)" */ public void setCurrentLocation(String theCurrentLocation) { currentLocation = theCurrentLocation; } /** * @return * @generated "UML to EJB (uml2.ejb.transformation)" */ public ISBNBook() { // TODO Auto-generated constructor stub //begin-user-code this.iSBNNumber = ""; this.bookName = ""; this.author = ""; this.currentLocation = ""; //sys data this.lastSearchDate = new Date(); this.obtainDate = new Date(); this.searchTimes = new Integer(0); //end-user-code } /** * @param isbnnumber * @return * @generated "UML to EJB (uml2.ejb.transformation)" */ public ISBNBook(String isbn) { //begin-user-code this(); this.iSBNNumber = isbn; //end-user-code } /** * @param isbnnumber * @param bookname * @param author * @param currentlocation * @return * @generated "UML to EJB (uml2.ejb.transformation)" */ public ISBNBook(String isbn, String name, String author, String curloc) { //begin-user-code this(); this.iSBNNumber = isbn; this.bookName = name; this.author = author; this.currentLocation = curloc; //end-user-code } public void insert(){ persist(this); } public void persist(Object object) { javax.persistence.EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("JPA_109948PU"); javax.persistence.EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); try { em.persist(object); em.getTransaction().commit(); } catch (Exception e) { e.printStackTrace(); em.getTransaction().rollback(); } finally { em.close(); } } }