0

我有一个休息服务,它有一个数据库。当我使用 entityfacade 将实体添加到 EJB 中的数据库时,一个实体变量价格需要一个实数。如果我从客户端将价格作为 xml 格式的字符串输入,则不会引发异常,并且数据库会注册 0。如果我使变量太大,则会引发正确的异常。

关于为什么会发生这种情况的任何想法?或者有没有办法将我的数据库表设置为仅接受整数?

@Entity
@Table(name = "BOOKS", catalog = "", schema = "DAVID")
@XmlRootElement

public class Books implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
//@NotNull
@Column(name = "BOOKID")
private Integer bookid;
@Basic(optional = false)
@NotNull
@Column(name = "ISBN")
private long isbn;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 40)
@Column(name = "PUBLISHER")
private String publisher;
@Column(name = "QUANTITY")
private int quantity;
@Basic(optional = false)
@NotNull
@Column(name = "PRICE")
private float price;

CREATE TABLE BOOKS (BOOKID INTEGER DEFAULT AUTOINCREMENT: start 1 increment 1  NOT NULL           GENERATED ALWAYS AS IDENTITY, ISBN BIGINT NOT NULL, TITLE VARCHAR(100) NOT NULL, COPYRIGHT VARCHAR(4) NOT NULL, PUBLISHER VARCHAR(40) NOT NULL, QUANTITY INTEGER, PRICE REAL NOT NULL, PRIMARY KEY (BOOKID));
4

0 回答 0