我数据库用的是sql server 2005,插入数据时提示:不能将值 NULL 插入列 'id'
各位帮忙看看什么原因,谢谢~~
代码如下:
持久化对象@Entity
@Table(name="d_cs_files")
public class DCsFile implements Serializable {
private static final long serialVersionUID = 1L; @Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private long id; private String author; private long bid; private String builder; private String code; @Column(name="contract_id")
private String contractId; private String monitor; private String note; private long pid; @Column(name="process_state")
private int processState; private int state; private String template; private long time; private String title; //bi-directional many-to-one association to DCsFileLog
@OneToMany
private List<DCsFileLog> DCsFileLogs;    public DCsFile() {
    } public long getId() {
return this.id;
} public void setId(long id) {
this.id = id;
} public String getAuthor() {
return this.author;
} public void setAuthor(String author) {
this.author = author;
} public long getBid() {
return this.bid;
} public void setBid(long bid) {
this.bid = bid;
} public String getBuilder() {
return this.builder;
} public void setBuilder(String builder) {
this.builder = builder;
} public String getCode() {
return this.code;
} public void setCode(String code) {
this.code = code;
} public String getContractId() {
return this.contractId;
} public void setContractId(String contractId) {
this.contractId = contractId;
} public String getMonitor() {
return this.monitor;
} public void setMonitor(String monitor) {
this.monitor = monitor;
} public String getNote() {
return this.note;
} public void setNote(String note) {
this.note = note;
} public long getPid() {
return this.pid;
} public void setPid(long pid) {
this.pid = pid;
} public int getProcessState() {
return this.processState;
} public void setProcessState(int processState) {
this.processState = processState;
} public int getState() {
return this.state;
} public void setState(int state) {
this.state = state;
} public String getTemplate() {
return this.template;
} public void setTemplate(String template) {
this.template = template;
} public long getTime() {
return this.time;
} public void setTime(long time) {
this.time = time;
} public String getTitle() {
return this.title;
} public void setTitle(String title) {
this.title = title;
} public List<DCsFileLog> getDCsFileLogs() {
return this.DCsFileLogs;
} public void setDCsFileLogs(List<DCsFileLog> DCsFileLogs) {
this.DCsFileLogs = DCsFileLogs;
}

}调用方法:public class FirstClient extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB(mappedName="ejb/manager/oa/FileManager")
    FileManager fileManager;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public FirstClient() {
        super();
        // TODO Auto-generated constructor stub
    } /**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
} /**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter(); out.print(fileManager.test());
DCsFile file = new DCsFile();
//file.setId(1l);
file.setAuthor("test");
file.setPid(1);
file.setBid(2);
file.setBuilder("builder1");
file.setMonitor("monitor1");
file.setContractId("contractid");
file.setTemplate("template1");
file.setProcessState(1);
file.setState(0);
file.setCode("abcde");
file.setTitle("title1");
file.setTime(new Date().getTime());
try {
fileManager.save(file);
} catch (BzException e) {
e.printStackTrace();
}
        //out.print("hello world");
out.close();
}}